VB icon

Personal StartUp! As simple as it can get...

Email
Submitted on: 1/2/2015 10:07:00 AM
By: Hyperswede (from psc cd)  
Level: Not Given
User Rating: By 102 Users
Compatibility: VB 5.0, VB 6.0
Views: 1135
 
     Do you use different user logins in Windows? Tired of having the same StartUp folder just because the users share the same Start Menu? Then this solves your problem!
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Personal StartUp! As simple as it can get...
'**************************************
Declare Function WNetGetUser Lib "mpr" _
Alias "WNetGetUserA" (ByVal lpName As _
String, ByVal lpUserName As String, _
lpnLength As Long) As Long
Public Function UserID() As String
Dim sUserNameBuffer As String * 255
sUserNameBuffer = Space(255)
Call WNetGetUser(vbNullString, _
sUserNameBuffer, 255&)
UserID = Left$(sUserNameBuffer, _
InStr(sUserNameBuffer, _
vbNullChar) - 1)
If UserID = "" Then UserID = "default"
End Function
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Personal StartUp! As simple as it can get...
' Description:Do you use different user logins in Windows?
Tired of having the same StartUp folder just because the users share the same Start Menu?
Then this solves your problem!
' By: Hyperswede (from psc cd)
'
' Inputs:How to use personal startups.
1) Add the source code below to a new project.
2) Make an exe file.
3) Create a shortcut in your StartUp folder that points to the exe.
4) Log Out and Log In again as the person you want to give personal startup.
5) Check in the directory where you put the exe.
6) Open the file UserID.txt with notepad (Replace UserID with yor UserID)
7) Add the path of the files you want to start when windows starts, separate the paths of the different files by hitting enter.
8) Done!
'
' Returns:Starts different programs on startup depending on the who has logged in.
'
' Side Effects:None that i know of.
'**************************************

Private Sub Form_Load()
Dim OpenWhat
'MsgBox UserID
On Error GoTo bwell
Open App.Path & "\" & UserID & ".txt" For Input As #1
On Error Resume Next
Do Until EOF(1)
Line Input #1, OpenWhat
Shell "Start " & OpenWhat
Loop
Close #1
End
bwell:
Open App.Path & "\" & UserID & ".txt" For Output As #2: Close #2
Resume
End Sub


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.