Making shortcuts on remote PCs using vbscript and psexec
Most of this information I'm taking from other websites, but I wanted a copy all in the same place.
computerperformance.co.uk
sysinternals tools from technet
mvps.org icon finder for Shell32 with numbers!
Basically you create a vbscript that makes a shortcut, using the mvps.org chart to assign the icon image you want, and then push that vbs file out using psexec cli tool from the sysinternals suite.
' Create ShortCut.vbs - Create a Desktop Shortcut.
' VBScript to create .lnk file
' Author Guy Thomas http://computerperformance.co.uk
' Version 2.4 - July 2006
' ----------------------------------------------------------'
Option Explicit
Dim objShell, objDesktop, objLink
Dim strAppPath, strWorkDir, strIconPath
' --------------------------------------------------
' Here are the variables that to change if you are making a 'real' script
strWorkDir ="C:\windows"
strAppPath = "http://tech.mikeal.com"
strIconPath = "%SystemRoot%\system32\SHELL32.dll,74"
Set objShell = CreateObject("WScript.Shell")
objDesktop = objShell.SpecialFolders("Desktop")
Set objLink = objShell.CreateShortcut(objShell.SpecialFolders("AllUsersDesktop") & "\Mikeal's Tech Blog.lnk")
' ---------------------------------------------------
' Section which adds the shortcut's key properties
objLink.Description = "Mikeal's Tech Blog"
objLink.HotKey = "CTRL+SHIFT+S"
objLink.IconLocation = strIconPath
objLink.TargetPath = strAppPath
objLink.WindowStyle = 3
objLink.WorkingDirectory = strWorkDir
objLink.Save
WScript.Quit
' End of creating a desktop shortcut
- strIconPath The 74 value in the is the number that selects the icon image. Check mvps.org to find the image and value you want.
- strAppPath is the url, or executable path for the shortcut.
- objShell.CreateShortcut Set the to the location you want the shortcut created.
- Modify the objLink.Description, and Hotkey as needed.
- Save the file as 'create myshortcut.vbs' and test it. If everything works correctly you can now take psexec and execute the script on other remote computers.
- To push out the vbs file you will need to make 2 batch files and a text file. You must place all these files, along with the psexec.exe file from the sysinternals package, on a network share. Make sure the share is accessible PCs the shortcut will be deployed to. The executable path has to work for the computers you are pushing it to.
- Launch.bat:
cscript "\\server\share\create myshortcut.vbs" - Install.bat:
psexec @workstations.txt -u domain\domainadmin -p myadminpwhere "\\server\share\launch.bat" - workstations.txt:
mypcname.mydomain.com
workstation2.mydomain.com
workstation3.mydomain.com
You can use IP address instead of DNS names in workstations.txt if needed.
When finished run the install.bat file from dos. install.bat will execute launch.bat on the remote computers listed in workstations.txt.
| Print article | This entry was posted by Mikeal on 08/27/10 at 09:56:12 pm . Follow any responses to this post through RSS 2.0. |