Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a way to programatically login to the network?
Message
From
19/01/1999 22:11:59
 
 
To
19/01/1999 12:57:52
General information
Forum:
Windows
Category:
Networking & connectivity
Miscellaneous
Thread ID:
00177673
Message ID:
00177875
Views:
31
>I have a job that runs at night on a machine that has no users logged on. I am trying to programatically log on to the network.
>
>I am using NT 4.0
>
>Does anyone know if you can do this in a batch file or any other way?

You can do this using the Wscript.Network Automation Object by attaching resources on a server; the Wscript.Network object's MapNetworkDrive method will accept a userid and password as the 4th and 5th arguments, which will be used when making the connection to the server. You'll need to install the Windows Scripting Host to use this; the Automation objects are usable from scripts, VB, VBA, VFP, etc.

If I've installed the WSH, the following VFP code works:

oNet = CREATEOBJ('Wscript.network')
oNet.MapNetworkDrive('H:', '\\MyServer\MyShare', .F., cUserName, cPassword)

In VBScript:

Set WshNet = Wscript.CreateObject("Wscript.Network")
WshNet.MapNetworkDrive "H:", "\\MyServer\MyShare", FALSE, "Username", "Password"
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform