Add program to startup
The following code can add you executable to startup so that when ever the user turn there computer on the program will load up.
Try
Dim appname As String = IO.Path.GetFileName(Application.ExecutablePath)
Dim vDirectory As String
vDirectory = "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\"
Dim zDir As New DirectoryInfo(vDirectory)
If Not zDir.Exists Then
My.Computer.FileSystem.CopyFile(Application.ExecutablePath, "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\" & appname, True)
Else
My.Computer.FileSystem.CopyFile(Application.ExecutablePath, "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\" & appname, True)
End If
Catch ex As Exception
End Try
No comments:
Post a Comment