Solth Posted April 2, 2009 Share Posted April 2, 2009 I am just trying to find a way to create a VB script that is designed to create a desktop shortcut(Under All Users) that points to a shared folder on one of our Microsoft servers, any assistance would be very helpful, Thank You in advance. Link to comment Share on other sites More sharing options...
0 Antaris Veteran Posted April 4, 2009 Veteran Share Posted April 4, 2009 You can use the WScript.Shell object to create this shortcut: Dim workingDirectory : workingDirectory = "C:\Windows" 'The shortcuts working directory. Dim application : application = "\\ServerPath\PathToApplication\Notepad.exe" 'The path to your application. Dim icon : icon = "%SystemRoot%\system32\shell32.dll,5" 'The icon, in this example load it from shell32.dll Dim shell : Set shell = CreateObject("WScript.Shell") Dim desktop : desktop = shell.SpecialFolders("AllUsersDesktop") Dim link : Set link = shell.CreateShortcut(desktop & "\NotepadShortcut.lnk") link.Description = "Notepad" link.HotKey = "CTRL+SHIFT+X" link.IconLocation = icon link.TargetPath = application link.WindowStyle = 3 link.WorkingDirectory = workingDirectory link.Save Hope that helps. There are a couple of things to note: You need to specifiy the target path using UNC path notations, unless you can guaruntee that each client machine has the network path mapped to the same drive letter. You use the SpecialFolders property to get the path of the All User's Desktop. There are other properties too (SpecialFolders Property @ MSDN). The icon you use can be a physical icon, or it can be a contained resource in a DLL. In the above example, we are pulling an icon out of shell32.dll The window style we use here (3) will cause the application to maximise in the foreground. (WindowStyle Property @ MSDN). I adapted this from Guy's Scripting Ezine 119 Link to comment Share on other sites More sharing options...
0 vks87 Posted April 16, 2009 Share Posted April 16, 2009 You can use the WScript.Shell object to create this shortcut: Dim workingDirectory : workingDirectory = "C:\Windows" 'The shortcuts working directory. Dim application : application = "\\ServerPath\PathToApplication\Notepad.exe" 'The path to your application. Dim icon : icon = "%SystemRoot%\system32\shell32.dll,5" 'The icon, in this example load it from shell32.dll Dim shell : Set shell = CreateObject("WScript.Shell") Dim desktop : desktop = shell.SpecialFolders("AllUsersDesktop") Dim link : Set link = shell.CreateShortcut(desktop & "\NotepadShortcut.lnk") link.Description = "Notepad" link.HotKey = "CTRL+SHIFT+X" link.IconLocation = icon link.TargetPath = application link.WindowStyle = 3 link.WorkingDirectory = workingDirectory link.Save Hope that helps. There are a couple of things to note: You need to specifiy the target path using UNC path notations, unless you can guaruntee that each client machine has the network path mapped to the same drive letter. You use the SpecialFolders property to get the path of the All User's Desktop. There are other properties too (SpecialFolders Property @ MSDN). The icon you use can be a physical icon, or it can be a contained resource in a DLL. In the above example, we are pulling an icon out of shell32.dll The window style we use here (3) will cause the application to maximise in the foreground. (WindowStyle Property @ MSDN). I adapted this from Guy's Scripting Ezine 119 Nice post a special thanks from myself........ Link to comment Share on other sites More sharing options...
Question
Solth
I am just trying to find a way to create a VB script that is designed to create a desktop shortcut(Under All Users) that points to a shared folder on one of our Microsoft servers, any assistance would be very helpful, Thank You in advance.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts