VBscript 中 WScript.Shell的使用 设置快捷方式

Window set up some templates for users to build reality and the WScript.Shell is one of the examples.

it has three personalities and nearly twelve functions.

three personalities 


This is an example. the shell is a reality and its three personalities are CurrentDirectory  | Environment  | SpecialFolders 

CreatShortcut is one of the functions.


'set up shortcut for one file
Dim shell,desktopPath,shortLnk
set shell=CreateObject("WScript.Shell")
desktopPath=shell.SpecialFolders("Desktop")     'the postion of shortcut
set shortLnk=shell.CreateShortcut(desktopPath &"\cmd.lnk")   ' set a reality of shortcut
shortLnk.TargetPath="C:\Windows\System32\cmd.exe"           ' the shortLnk is the shortcut of cmd.exe 
shortLnk.WorkingDirectory="C:\Windows\System32"             ' this is where the cmd is
shortLnk.Save()                                             ' you need to make the shortLnk become a reality not just in the memory


你可能感兴趣的:(VBscript 中 WScript.Shell的使用 设置快捷方式)