[How to] Create shortcut using VBS script

After a long time I am again back to my blog….it has been almost 2 months I was on vacation. Now just returned to my normal life. Few days ago, I have an issue of creating a automatic shortcut on the desktop of the machine which was the member of the domain. I Struggle with a lot of scripts and moved on…. but finally with the help of technet and msdn I got the solution and trying to share my knowledge over here.

Here is the script what I wrote on notepad and save it as the Extension of *.vbs.

set WshShell = WScript.CreateObject("WScript.Shell" )
strDesktop = WshShell.SpecialFolders("AllUsersDesktop" ) 'location where needed to be save.
set oShellLink = WshShell.CreateShortcut(strDesktop & "notepad++.lnk" ) ' name of the shortcut file.
oShellLink.TargetPath = "C:Program Files (x86)Notepad++notepad++.exe"
oShellLink.WindowStyle = 1
oShellLink.IconLocation = "c:application folderapplication.ico"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = "C:Program Files (x86)Notepad++"
oShellLink.Save

 

I have done here with the Notepad++ as an example. after making this script, I applied this script on the Domain Group Policy.
User Configuration–>Windows Settings –> Scripts–> Logon

Add a Script with the above code on this place and update the group policy by command line ‘gpupdate /force’

After Completing all the steps on the Server Machine, get login on the client machine with administrative privilege and provide the modification permission to the domain users on root drive (i.e. C:) or
For windows 7 machine
Edit the folder located on C:usersPublicPublic Desktop or C:usersPublicDesktop with modify permission for the domain users

For Windows XP machine.
Edit the folder located on C:Documents and settingsAll UsersDesktop with modify Permission for the domain users.
. so that you do not require the administrative privilege to run and paste the script on your desktop.

I hope this will be helpful to you guys.

🙂

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.