|
Answer» Hi,
I've tried to manage to create a SHORTCUT after mapping the network drive using VBscript. This is my first TRIAL. I was wondering if anyone might be able to help me fix this. Mapping the network drive is working. But when i tried to incorporate the shortcut script into the mapping network drive, that's when it's not working.
Here is my code. Option Explicit Dim objNetwork Dim strUser, strPassword, strProfile Dim strDriveLetter, strRemotePath Dim WshShell ' Object variable Dim strTargetPath Dim strWorkingDir
' Values of VARIABLES SET for Drive H strDriveLetter = "H:" strRemotePath = "\\192.168.2.11\netlogon" strUser = "myuser" strPassword = "mypasswd" strProfile = "false"
' This section creates a network object. (objNetwork) ' Then apply MapNetworkDrive method. RESULT H: drive ' Note, this script features 5 arguments on lines 21/22. Set objNetwork = WScript.CreateObject("WScript.Network")
' Section which maps two drives, H: and J: objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, _ strProfile, strUser, strPassword
' Create new WshShell object, whose CreateShortcut method we need. Set WshShell = WScript.CreateObject("WScript.Shell")
Dim MyShortcut Dim MyDesktop Dim DesktopPath Dim TargetPath
strTargetPath = "H:\\192.168.2.11\netlogon" strWorkingDir = "My Computer"
DesktopPath = WSHShell.SpecialFolders("Desktop") Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\test.lnk") MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings(strTargetPath) MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings(strWorkingDir) MyShortcut.Save
YOur help is greatly appreciated. Thank you in advance
|