I have a VB script that adds a program shortcut to the Windows Startup folder. In my script, I'm able to retrieve the Startup folder location in 32-bit Windows with this:
Set objShell = CreateObject("WScript开发者_StackOverflow.Shell")
startupFolder = objShell.SpecialFolders("Startup")
but it returns nothing when I try this on 64-bit Windows. Specifically, I'm testing on 64-bit Vista. I can't seem to find the appropriate environment variable or syntax for this. Thanks.
Try an alternative variant 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?
See if this works. This actually reads the registry value where the folder is stored. I can' imagine why the other method doesn't work in 64-bit.
Dim startupFolder As String startupFolder = My.Computer.Registry.GetValue _ ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Startup", Nothing)
精彩评论