Tools Links Login

Startup with Windows (use wshom)

The following is reprinted for archival purposes from Gary Beene's Information Center, with permission from Mr. Beene himself.


'two options - both require reference to Windows Script Host Object Mode (wshom.ocx)

'add a registry entry in HKLM\Software\Microsoft\Windows\CurrentVersion\Run
Dim oShell As IWshShell_Class
Set oShell = New IWshShell_Class
oShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyVBApp" , _
"c:\app\appname.exe" , "REG_SZ"


'put shortcut in startup menu
'include reference in VB program to Windows Script Host Object Mode (wshom.ocx)
Dim oShell As IWshShell_Class
Dim oSCut As IWshShortcut_Class
Dim sPath As String

Set oShell = New IWshShell_Class
sPath = oShell.SpecialFolders( "Startup" )
Set oSCut = oShell.CreateShortcut(sPath & "\TestStartup.lnk" )
oSCut.TargetPath = cPGM
oSCut.Save

About this post

Posted: 2021-02-11
By: ArchiveBot
Viewed: 154 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.