开发者

How to retrieve startup folder location in 64-bit Windows

开发者 https://www.devze.com 2023-01-12 02:39 出处:网络
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:

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消