真相:我对这个脚本完全陌生,已经走到了尽头。我正在尝试编写一个脚本,该脚本不仅会在用户桌面上创建快捷方式,而且当用户单击图标时,我希望他们被询问是否真的要关闭计算机并提供取消选项关机或继续关机。到目前为止,我已经搜索到我的教科书和谷歌的末尾。我可以创建一个图标并让它执行 Windows 本机关闭,但不能通过我的特殊干预操作。我只是不知道如何将图标回调到选择案例例程的脚本中......对不起,如果有点混乱见下文:
result = MsgBox ("Would you really like to Shutdown?", vbYesNo, "Shutdown?")
Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
' Add Shutdown link to the desktop
Set linkShutdown = Shell.CreateShortcut(DesktopPath & "\Shutdown.lnk")
linkShutdown.Description = "Shutdown the computer"
linkShutdown.IconLocation = ("%SystemRoot%\system32\SHELL32.dll,27")
linkShutdown.TargetPath = "shutdown"
linkShutdown.WindowStyle = 1
linkShutdown.WorkingDirectory = "%windir%"
linkShutdown.Save
Select Case result
Case vbYes
MsgBox("Shutting down ...")
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
Case vbNo
MsgBox("Ok")
End Select