File plugin ->createShortcut (files/folders)

Hello everybody,

Id like to create a shortcut on the users desktop to point to a hidden networkdirectory, but to my supprise I couldnt find this function in the file plugin. Is it possible to add it in the file plugin?

createShortcut(shortcutLocation, shortcutDestination, shortcutName)

I don`t know if this is only a Windows thing but I use it a lot.

Thanks a lot and keep up the good work.

I tried to get it working with plain Javascript but the method editor doesn`t recognize the “WScript.Shell” object.

var WshShell = new ActiveXObject("WScript.Shell"); 
//var WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop");
var oShellLink = WshShell.CreateShortcut(strDesktop + "\\Release RvdV.lnk");
oShellLink.TargetPath = "H:\\Vanderlande\\DPD\\Release\\Users\\RvdV\\"
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+R"
oShellLink.IconLocation = "explorer.exe, 15"
oShellLink.Description = "Shortcut To DPD Release Folder."
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save()

Either one of the first 2 lines work in a js file but don`t in the method editor.
Does anyone know a way around this (html???)

Ps every user has his own destination folder therefore I want to initialize it from Servoy. A writeToFile → execute → delete is an alternative but not a very nice one.

Thanks in advance Rene.

It is not possible to create shortcuts in Servoy (its very different for each platform and creating shortcuts has nothing todo with Servoy we think)

What you could do is open a browser like:
application.showURL(‘H:\Vanderlande\DPD\Release\Users\RvdV\’)

Jan Blok:
It is not possible to create shortcuts in Servoy (its very different for each platform and creating shortcuts has nothing todo with Servoy we think)

What you could do is open a browser like:
application.showURL(‘H:\Vanderlande\DPD\Release\Users\RvdV\’)

Although you could convert your code into the VBScript equivalent then simply call that code to run. You can create the VBScript within Javascript and write it out of your Servoy app OR you can carry the VBScript within a BLOB field and simply dump it out into the C:\Windows\Temp or %temp% then execute it.

NT.js.zip (3.78 KB)

Hello guys,

Yes Matt I allready have created a simular thing you describe.

For anyone interested.

Create a variable and write the complete JS code in it. Use the escape code character \ for fixed quotes " and returns \n

Write a textfile containing the variable

Wait for the file to be created

Run the file according to the fileprotocolhandler

Wait for the application to run

Delete the file

var JS_File = "var WshShell = WScript.CreateObject(\"WScript.Shell\")\nvar oShellLink = WshShell.CreateShortcut(\"" + utils.stringReplace(plugins.file.getDesktopFolder(), "\\", "/") + "/Release " + globals.GT_Field_User_Initials + ".lnk\")\noShellLink.TargetPath = \"" + utils.stringReplace(globals.GT_ReleasePath, "/", "\\\\") + globals.GT_Field_User_Initials + "\\\\\"\noShellLink.WindowStyle = 1\noShellLink.Hotkey = \"CTRL+SHIFT+R\"\noShellLink.IconLocation = \"explorer.exe, 15\"\noShellLink.Description = \"Shortcut to your DPD Release folder.\"\noShellLink.WorkingDirectory = \"" + utils.stringReplace(plugins.file.getDesktopFolder(), "\\", "/") + "\"\noShellLink.Save()"

application.writeTXTFile(plugins.file.getDesktopFolder() + "\\Create DPD Shortcut.js", JS_File)

application.sleep(100)

var Open = application.executeProgram( 'rundll32',  'url.dll,FileProtocolHandler', plugins.file.getDesktopFolder() + "\\Create DPD Shortcut.js")

application.sleep(100)

plugins.file.deleteFile(plugins.file.getDesktopFolder() + "\\Create DPD Shortcut.js")

PS only tried it on Windows XP yet.

Thanks for replying Jan and Matt

servoyUpdater.jar (289 KB)