p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VB How-To (http://p2p.wrox.com/forumdisplay.php?f=78)
-   -   Mapping and Connecting to other machine (http://p2p.wrox.com/showthread.php?t=386)

delcyan June 10th, 2003 11:20 AM

Mapping and Connecting to other machine
Hello All,

I have an application that runs overnight and need to connect to all servers and do someting.

I have a batch file which consist of the following examples:

rem *** ST01A02 ***
map root t:=\\st01a02\sys
purge *.* /a

map root t:=\\st01a02\data02a
purge *.* /a

map root t:=\\st01a02\data02b
purge *.* /a

This batch file map to the machine and give it a letter t.

Is there a way to map and connect to servers in VB, do someting (run application) and then disconnect from that machine and repeat this process as needed?

Thank you

Web Administrator

pgtips June 11th, 2003 03:39 AM

Take a look at the Windows Scripting Host stuff, specifically the WshNetwork object which has methods MapNetworkDrive and RemoveNetworkDrive.

BTW if you just want to work with files on remote machines you can use the FileSystemObject which accepts UNC paths, so no need to map a drive at all.

Also, the Remote Scripting capabilities may be of interest to you - depends exactly what you want to do.


delcyan June 11th, 2003 08:26 AM

Thank you Phil, this is exactly what I found out yesterday from the MSDN online.

I tried it and it worked just like I was hoping.

Again, thank you all

Web Administrator

delcyan June 11th, 2003 10:33 AM

Hello all,

I have been able to map the drive from VB using the wshom reference. See code below:

----Start code
Dim objMap As WshNetwork

Set objMap = New WshNetwork
Call objMap.MapNetworkDrive(pstrMapDriveLetter, pstrPathToMap, True)
-----End Code

Yesterday, everything was working as expected but today it failed to map that same drive.
See error:

Automation error
The specified device name is invalid.

my Drive Letter

Path that I am mapping to

Does anybody knows what is happening here?

Thank you

Web Administrator

pgtips June 12th, 2003 04:50 AM

sounds like your network connection is playing up. Can you browse to \\Stn006d\Data06a using Explorer?

All times are GMT -4. The time now is 01:03 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.