Creating shortcut to executable using vbs script

September 5, 2012 at 10:14:15
Specs: Windows 7

I have this script to create a shortcut to my desktop :

Set oWS = WScript.CreateObject("WScript.Shell")
shortCut = "C:\Users\%userprofile%\desktop\PPPM.lnk"
Set oLink = oWS.CreateShortcut(shortCut)
oLink.TargetPath = "C:\GoogleChromePortable\inicio.exe"
oLink.WorkingDirectory = "C:\GoogleChromePortable"

The script works fine and the PPPM.Ink shortcut is created as long as I don't
place it on my desktop. It doesn't seem to recognize the path to %homepath%, %ALLUSERSPROFILE% or %userprofile%. Where is the problem ?
What is the standard path to anybody's desktop ? Any suggestion on making this script work ?

See More: Creating shortcut to executable using vbs script

Report •

September 5, 2012 at 11:08:28

:: mike

Report •

September 5, 2012 at 12:45:31
on windows seven machine, yes. if any machines are or might be xp, then your code should account for that possibility.

Report •

September 6, 2012 at 06:12:51
shortCut = "C:\Users\%userprofile%\desktop\PPPM.lnk"
I'm amazed it works on any copy of windows, considering it's an invalid path. Also, I don't think CreateShortcut performs variable expansion, so it should choke on that as well.

How To Ask Questions The Smart Way

Report •
Related Solutions

Ask Question