[英]Unable to create shortcut on Desktop for a remote IP file
I am using below code to create the help.lnk (which refers to MainHelp.html) from a remote IP to my local system. 我正在使用下面的代码从远程IP到本地系统创建help.lnk(指MainHelp.html)。 I am facing below problems:
我面临以下问题:
On my friend's PC the "help.lnk" is targeting to "C:\\172.xx.xx.xx\\abc\\html\\MainHelp.html" ,which is wrong as "C:" must not come because the MainHelp.html is present at remote IP.So, its giving Target Not Found ERROR 在我朋友的PC上,“ help.lnk”的目标是“ C:\\ 172.xx.xx.xx \\ abc \\ html \\ MainHelp.html”,因为“ C:”一定不正确,因为MainHelp.html出现在远程IP上,因此其给定目标未找到错误
function fnGo() { 函数fnGo(){
var WshShell = new ActiveXObject("WScript.Shell"); strDesktop = WshShell.SpecialFolders("\\\\172.xx.xx.xx\\\\abc\\\\html"); var oShellLink = WshShell.CreateShortcut(strDesktop + "help.lnk"); oShellLink.TargetPath = "\\\\172.xx.xx.xx\\\\abc\\\\html\\\\MainHelp.html"; oShellLink.WindowStyle = 1; oShellLink.Hotkey = "CTRL+SHIFT+G"; oShellLink.Description = "Shortcut Script"; oShellLink.WorkingDirectory = strDesktop; oShellLink.Save();
} }
Please help 请帮忙
Try changing the following lines 尝试更改以下几行
strDesktop = WshShell.SpecialFolders("Desktop");
var oShellLink = WshShell.CreateShortcut(strDesktop + "\\help.lnk");
oShellLink.TargetPath = "\\\\172.xx.xx.xx\\abc\\html\\MainHelp.html";
You need to indicate the correct folder in where to save the shortcut 您需要在保存快捷方式的地方指定正确的文件夹
It is necessary to separate the name of the shortcut file and the name of the folder 有必要将快捷方式文件的名称和文件夹的名称分开
In javascript, every backslash needs to be escaped, so every backslash needs to be doubled. 在javascript中,每个反斜杠都需要转义,因此每个反斜杠都需要加倍。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.