vbs下一些取特殊路径的方法总结

1、用FSO的SpecialFolder常数

FSO的SpecialFolder常数依赖的函数为GetSpecialFolder(SpecialFolder),很遗憾的是,SpecialFolder常数只有3个,0-2,0对应WindowsFolder,就是你的Windows文件夹,如果你的系统装在C盘的话,那么返回的就是"C:\Windows"这个路径字符串。1对应SystemFolder,GetSpecialFolder(1)返回"C:\Windows\system32"。2代表临时文件夹,就不要我多说了吧?

下面给出取临时文件夹路径字符串的实例:

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject") //绑定FSO对象
Dim tempfolder
Const TemporaryFolder = 2
Set tempfolder = fso.GetSpecialFolder(TemporaryFolder)
Wscript.Echo tempfolder

继续阅读

vbs脚本创建windows快捷方式

'Create a WshShell Object
Set WshShell = Wscript.CreateObject("Wscript.Shell")

'currentpath
path=createobject("Scripting.FileSystemObject").GetFolder(".").Path

'Set the Target Path for the shortcut
oShellLink.TargetPath = path & "\php-win.exe"

'Set the additional parameters for the shortcut
oShellLink.Arguments = "bin\main.php"

'1:default 3:Maximize 7:Minimize
oShellLink.WindowStyle = 3

'hotKey
oShellLink.Hotkey = "Ctrl+Alt+e"

'desc
oShellLink.Description = "this is a php grograme"

'workingDirectory
oShellLink.WorkingDirectory = path

'icon
oShellLink.IconLocation = path & "\zs.ico"

'Save the shortcut
oShellLink.Save

'Clean up the WshShortcut Object
Set oShellLink = Nothing