Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2003, 11:20 AM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
t:
purge *.* /a

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

map root t:=\\st01a02\data02b
t:
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



A.Delcy
Web Administrator
Canada
__________________
A.Delcy
Developer
Canada
 
Old June 11th, 2003, 03:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.

hth
Phil
 
Old June 11th, 2003, 08:26 AM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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



A.Delcy
Web Administrator
Canada
 
Old June 11th, 2003, 10:33 AM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
"T:"

Path that I am mapping to
"\\Stn006d\Data06a"

Does anybody knows what is happening here?

Thank you

A.Delcy
Web Administrator
Canada
 
Old June 12th, 2003, 04:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Retore Db from a remote machine to a local machine srkvellanki BOOK: Beginning SQL 0 October 3rd, 2008 05:17 PM
Copy from one machine to another machine somnath.kartic SQL Server 2000 2 January 12th, 2006 03:13 PM
Character Mapping muki XSLT 2 November 11th, 2005 03:11 AM
O/R mapping s_sana General .NET 0 April 12th, 2005 06:34 AM
mapping a database. kyootepuffy Classic ASP Databases 11 August 22nd, 2003 03:32 AM





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