How to get startup folder location on 64-bit Windows

I have a VB script that adds a program shortcut to the Windows startup folder. In my script, I can get the location of the Startup folder on 32-bit Windows using this:

Set objShell = CreateObject("WScript.Shell") startupFolder = objShell.SpecialFolders("Startup") 

but it doesn’t return anything when I try to do this on 64-bit Windows. In particular, I am testing 64-bit Vista. It seems I cannot find a suitable environment variable or syntax for this. Thanks.

+4
source share
2 answers

Try an alternative using the Shell.Application object:

 Const ssfSTARTUP = &H7 Set oShell = CreateObject("Shell.Application") Set startupFolder = oShell.NameSpace(ssfSTARTUP) If Not startupFolder Is Nothing Then WScript.Echo startupFolder.Self.Path End If 

Does it work for you?

+5
source

See if this works. This actually reads the value of the registry in which the folder is stored. I can imagine why the other method does not work in the 64-bit version.

  Dim startupFolder As String
 startupFolder = My.Computer.Registry.GetValue _
 ("HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ User Shell Folders", "Startup", Nothing)
+1
source

All Articles