Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Make network connection from scheduled task
Message
From
05/11/2004 17:48:04
 
 
To
05/11/2004 17:29:45
Guy Pardoe
Pardoe Development Corporation
Peterborough, New Hampshire, United States
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00958713
Message ID:
00958718
Views:
19
Guy,

You can create .vbs files that will map and unmap drives on the fly.
These Windows script files can be called by Scheduler or VFP.
Of course your admin username and password must successfully authenticate in any server you are mapping.

This code will map 5 drives:
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")

objNetwork.MapNetworkDrive "I:", "\\Aseserver\I", True
objNetwork.MapNetworkDrive "J:", "\\Aseserver\J", True
objNetwork.MapNetworkDrive "K:", "\\Aseserver\k", True
objNetwork.MapNetworkDrive "H:", "\\Aseserver\k", True
objNetwork.MapNetworkDrive "S:", "\\Shopserver\Data (D)", True
This code will unmap all drives:
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")

Set colDrives = objNetwork.EnumNetworkDrives
i = 0
For i = 0 to colDrives.Count-1 Step 2
   strDrive = colDrives.Item(i)
   objNetwork.RemoveNetworkDrive strDrive, True, True
Next
Thanks
Gaylen Miller
Previous
Reply
Map
View

Click here to load this message in the networking platform