vbscript 字符串中的引号导致 wsh 无效 url 错误

发布于 2024-07-15 09:06:04 字数 866 浏览 7 评论 0原文

我试图让下面的脚本生成这样的快捷方式:

“C:\Program Files\Internet Explorer\iexplore.exe” http://WebApp/index.aspx

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oUrlLink = WshShell.CreateShortcut(strDesktop & "\WebApp.url")
oUrlLink.TargetPath = ""&chr(34)& _
  "C:\Program Files\Internet Explorer\iexplore.exe" & _
   chr(34)&" http://WebApp/index.aspx"
oUrlLink.Save

但是它似乎不喜欢引号。

我在 URL 中收到无效语法: ""C:\Program Files\Internet Explorer\iexplore.exe" http://WebApp /index.aspx”。

如何在 VBScript 不打结的情况下嵌入 " ?

I'm trying to get the script below to produce a shortcut like this:

"C:\Program Files\Internet Explorer\iexplore.exe" http://WebApp/index.aspx

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oUrlLink = WshShell.CreateShortcut(strDesktop & "\WebApp.url")
oUrlLink.TargetPath = ""&chr(34)& _
  "C:\Program Files\Internet Explorer\iexplore.exe" & _
   chr(34)&" http://WebApp/index.aspx"
oUrlLink.Save

but it doesn't seem to like the quotes.

I get an Invalid Syntax in URL: ""C:\Program Files\Internet Explorer\iexplore.exe" http://WebApp/index.aspx".

How can I embed a " without vbscript getting its knickers in a knot?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

药祭#氼 2024-07-22 09:06:04

这是根据 Microsoft 的说法:

Set objShell = CreateObject("Wscript.Shell")
strFolder = objShell.SpecialFolders.Item("Desktop")
Set objShortcut = objShell.CreateShortcut(strFolder & "\Open Web Site.lnk")
objShortcut.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe"
objShortcut.Arguments = "http://WebApp/index.aspx"
objShortcut.Save

您必须使用 .lnk 作为文件扩展名,而不是 .url,因为 .Arguments 属性仅适用于 .lnk

This is according to Microsoft:

Set objShell = CreateObject("Wscript.Shell")
strFolder = objShell.SpecialFolders.Item("Desktop")
Set objShortcut = objShell.CreateShortcut(strFolder & "\Open Web Site.lnk")
objShortcut.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe"
objShortcut.Arguments = "http://WebApp/index.aspx"
objShortcut.Save

You have to use .lnk for the file extension, not .url as the .Arguments property is only available for .lnk

情独悲 2024-07-22 09:06:04

这有效吗?

oUrlLink.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe"
oUrlLink.Arguments = "http://WebApp/index.aspx"
oUrlLink.Save

Does this work?

oUrlLink.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe"
oUrlLink.Arguments = "http://WebApp/index.aspx"
oUrlLink.Save
御守 2024-07-22 09:06:04

在 VB 中转义引号 - 总是很痛苦。

oUrlLink.TargetPath = """C:\Program Files\Internet Explorer\iexplore.exe"" http://WebApp/index.aspx"

Escaping quotes in VB - always painful.

oUrlLink.TargetPath = """C:\Program Files\Internet Explorer\iexplore.exe"" http://WebApp/index.aspx"

别想她 2024-07-22 09:06:04

你试过这个吗?

oUrlLink.TargetPath = chr(34) & "C:\Program Files\Internet Explorer\iexplore.exe" & _
                      chr(34) & " http://WebApp/index.aspx"

有关引用的更多信息,请访问此处

Have you tried this?

oUrlLink.TargetPath = chr(34) & "C:\Program Files\Internet Explorer\iexplore.exe" & _
                      chr(34) & " http://WebApp/index.aspx"

More about quoting can be found here.

梦冥 2024-07-22 09:06:04

这对我有用:

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oUrlLink = WshShell.CreateShortcut(strDesktop & "\WebApp.url")
oUrlLink.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe http://WebApp/index.aspx"
oUrlLink.Save

This worked for me:

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oUrlLink = WshShell.CreateShortcut(strDesktop & "\WebApp.url")
oUrlLink.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe http://WebApp/index.aspx"
oUrlLink.Save
无需解释 2024-07-22 09:06:04

用这个作为目标路径


"C:\Program Files\Internet Explorer\iexplore.exe http://WebApp/index.aspx"

这个怎么样


Target= "http://WebApp/index.aspx"

Use this as the target path


"C:\Program Files\Internet Explorer\iexplore.exe http://WebApp/index.aspx"

How about this


Target= "http://WebApp/index.aspx"

风吹过旳痕迹 2024-07-22 09:06:04
Set objShell = WScript.CreateObject("WScript.Shell" )
strDesktopFolder = objShell.SpecialFolders("Desktop") 
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & "\test.lnk" ) 
objShortCut.TargetPath = "http://www.google.com/" 
objShortCut.Description = "Test Environment" 
objShortCut.Save 

上面的方法对我来说效果很好,可以将快捷方式部署到桌面作为 GPO 的一部分。 为了保护无辜者,这些名字已被更改。

我的想法似乎更清晰一些,但无论如何我都不是脚本大师。

Set objShell = WScript.CreateObject("WScript.Shell" )
strDesktopFolder = objShell.SpecialFolders("Desktop") 
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & "\test.lnk" ) 
objShortCut.TargetPath = "http://www.google.com/" 
objShortCut.Description = "Test Environment" 
objShortCut.Save 

The above worked fine for me for deploying shortcuts to desktops as part of a GPO. The names have been changed to protect the innocent.

Seems a bit cleaner to my mind but i'm not a script guru by any means.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文