Automatically creating shortcut

G

Guest

Hello everybody

I need some help on this: I need to automatically create a desktop shortcut
when a user first logs into her (his) Terminal server session, the problem is
that the shortcut must point to a location under her(his) documents path, so
I need to be able to introduce a variable %USERNAME% into the desktop shorcut
creation in order to be created pointing to the right place.

Any ideas?

Thanks
 
N

Nathan

Hi Alfredo

You can use this to create the shortcut

Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
Dim MyShortcut, MyDesktop ', DesktopPath
' Create a shortcut object on the desktop
strUserProfile = WSHShell.ExpandEnvironmentStrings("%userprofile%")
Set MyShortcut = WSHShell.CreateShortcut(strUserProfile & "\Desktop\Link
Name.lnk")

' Set shortcut object properties and save it
MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("c:\program
files\program folder\program.exe")
MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("c:\program
files\program folder")
MyShortcut.WindowStyle = 4
MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("c:\program
files\program folder\program.exe, 0")
MyShortcut.Save

I think that should work

Nathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top