Question

I am using below code to create the help.lnk (which refers to MainHelp.html) from a remote IP to my local system. I am facing below problems:

  1. The same code is running on my friends PC but not mine.Its saying = "Automation server can't create object"
  2. 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

    function 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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top