I have a VBSCRIPT that does that. Run this as a shortcut, Use Arguments drive=X: Path=\\xxx\xxx.exe
Option Explicit
'Declare Global Variables
Dim NRArray(1,2), TempArray, objArgs, I
'Set Argument List
Set objArgs = WScript.Arguments
If objArgs.Count <> 3 then
MsgBox "Incorrect number of arguments. NRMap will not launch"
Else
For I = 0 to objArgs.Count - 1
TempArray = Split(objArgs(I), "=")
If lcase(TempArray(0)) = "drive" then
NRArray(0,0) = TempArray(0)
NRArray(1,0) = TempArray(1)
ElseIf lcase(TempArray(0)) = "path" then
NRArray(0,1) = TempArray(0)
NRArray(1,1) = TempArray(1)
Else
NRArray(0,2) = TempArray(0)
NRArray(1,2) = TempArray(1)
End If
'WScript.Echo objArgs(I)
Next
End If
CALL Network()
Function Network()
Dim clDrives, wshNetwork, wshshell, Result, TmpArray, StrPath, NRRun, oExec, MappingExist
MappingExist = 0
Set WshShell = Wscript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
'WScript.Echo clDrives.Item(i)
If ucase(clDrives.Item(i)) = ucase(NRArray(1,0)) Then
'msgbox "Drive already mapped. Deleting..."
if ucase(clDrives.Item(i + 1)) <> ucase(NRArray(1,1)) then
WshNetwork.Removenetworkdrive NRArray(1,0), True
Else
MappingExist = 1
End If
End if
Next
If MappingExist = 0 then
WshNetwork.Mapnetworkdrive NRArray(1,0), NRArray(1,1), False
End If
NRRun = NRArray(1,0) + "\" + NRArray(1,2)
WshShell.CurrentDirectory = Left(NRRun, InstrRev(NRRun, "\"))
'WScript.Echo WshShell.CurrentDirectory
WshShell.Run NRRun
'WshShell.Run NRRun,,True
'App finished, disconnecting drive...
'WshNetwork.Removenetworkdrive NRArray(1,0), True
'For BOS this could not remain because on first launch the application spawns another 'process which the script could not follow
END FUNCTION
Regards
Mike