Vbscript 修改快捷目标路径?
我需要使用以下VBScript将快捷目标路径从“google.com”更改为“yahoo.com”:Vbscript 修改快捷目标路径?,vbscript,shortcut,Vbscript,Shortcut,我需要使用以下VBScript将快捷目标路径从“google.com”更改为“yahoo.com”: Set sh = CreateObject("WScript.Shell") Set shortcut = sh.CreateShortcut("C:\Wherever\Shortcut.lnk") shortcut.TargetPath = "C:\Program Files(x86)\Internet Explorer\iexplore.exe" http://www.google.com"
Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut("C:\Wherever\Shortcut.lnk")
shortcut.TargetPath = "C:\Program Files(x86)\Internet Explorer\iexplore.exe" http://www.google.com"
shortcut.Save
当我从CMD运行此命令时
cscript file.vbs
我得到以下错误:
声明的例外结尾
我需要添加
或其他内容吗?这对我很有用:
Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut("C:\temp\Shortcut.lnk")
shortcut.TargetPath = "c:\temp"
shortcut.Save
另外,在我创建c:\where\
之后,您的脚本工作得非常好
如果在确保文件夹存在后仍不起作用,请发布错误。目标路径字符串的语法不正确。您需要在整个字符串周围加上双引号,还需要在字符串内的InternetExplorer路径周围加上转义双引号,因为该路径包含空格。在VBScript中,可以通过将双引号加倍来转义字符串中的双引号 更改此行:
shortcut.TargetPath = "C:\Program Files(x86)\Internet Explorer\iexplore.exe" http://www.google.com"
为此:
shortcut.TargetPath = """C:\Program Files(x86)\Internet Explorer\iexplore.exe"" http://www.google.com"
错误也会消失。你的脚本对我来说很好,即使有奇怪的间距。请发布您收到的错误。