Roberto Alves

Scripting and server based computing

VBS to map network drivers and run an application

Here we have a simple VBS that can be used at published aplicattions on Citrix XenApp (Presentation Server), or running local applications with their necessary mapped network drivers.
This script map network drivers and open an application.

Letra = “S:”
‘Precisa ser letra maiuscula
Caminho = servidorshare
Aplicativo = Letra & “teste.exe”

Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set WshNetwork = WScript.CreateObject(“WScript.Network”)
Set AllDrives = WshNetwork.EnumNetworkDrives()
driveconectado = False
For i = 0 To AllDrives.Count – 1 Step 2
If AllDrives.Item(i) = Letra Then driveconectado = True
If driveconectado = True then
WShNetwork.RemoveNetworkDrive Letra
End if
WShNetwork.MapNetworkDrive Letra, Caminho
WshShell.Run Aplicativo

Category: Scripts

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