Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB Script mapping network drives

Posted on 2008-10-21
6
434 Views
Last Modified: 2010-04-21
hello,

i have a vb script that uninstalls an older version of a software product and then installs a new version of the software product. however, after installation i need to call a batch file that resides on a network drive. i cannot figure out how to map the drive call the file and then delete the mapping. any insight would be appreciated. attached a my script. thanks in advance.

chaz.
'Create command shell
Set WshShell = CreateObject("WScript.Shell")
 
'Uninstall previous versions of FileSite
WshShell.Run "msiexec /x {ABD11761-F3F5-421D-8726-5CCEEE333AA8} /q",1,true
WshShell.Run "msiexec /x {67F84002-C577-41C7-8F02-682A7797EE16} /q",1,true
 
'Install new version of FileSite
WshShell.Run "msiexec.exe /i ""\\archive\archive\software\Interwoven\FileSite 8.2 SP1 P3a\Full_Installer\Interwoven FileSite 8.2 SP1.msi"" /qn SERIALNUMBER=""xxx-xxx"" ", 1, true

Open in new window

0
Comment
Question by:chaz21
6 Comments
 
LVL 5

Expert Comment

by:lecaf
ID: 22770979

why use VBS?

go for a plain batch

and you can the use the pushd and popd commands
PUSHD will create a temporary drive letter that points to that specified network resource and then change the current drive and directory, using the newly defined drive letter

you could also use em with shell run but Iit would be bizzare.

m  a  r  c .
0
 
LVL 8

Accepted Solution

by:
MatthiasVance earned 500 total points
ID: 22771049
I provided some example code.

Kind regards,

Matthias Vance
Dim oNet
Set oNet = CreateObject("WScript.Network")
oNet.MapNetworkDrive "H:", "\\server\path"
' Your code here
oNet.RemoveNetworkDrive "H:"

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22771096
Hi, you should be able to run your batch file directly from the UNC path without having to map a network drive....

Try this.

Regards,

Rob.
'Create command shell
Set WshShell = CreateObject("WScript.Shell")
 
'Uninstall previous versions of FileSite
WshShell.Run "msiexec /x {ABD11761-F3F5-421D-8726-5CCEEE333AA8} /q",1,true
WshShell.Run "msiexec /x {67F84002-C577-41C7-8F02-682A7797EE16} /q",1,true
 
'Install new version of FileSite
WshShell.Run "msiexec.exe /i ""\\archive\archive\software\Interwoven\FileSite 8.2 SP1 P3a\Full_Installer\Interwoven FileSite 8.2 SP1.msi"" /qn SERIALNUMBER=""xxx-xxx"" ", 1, True
 
'Run the batch file
strBatch = "\\server\share\MyBatch.bat"
WshShell.Run strBatch, 1, True

Open in new window

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:chaz21
ID: 22771205
thanks for responding so quickly  !! ill give these suggestions a try and report back asap.
0
 

Author Comment

by:chaz21
ID: 22798078
attached is my script that is working just the way i intended !!   it runs perfectly when i initiate it on the local machine as admin.  now my next step is to get my sms package to run this on all the clients on our network. i created an sms package that calls the same script and it fails. anyone have any sms experience ?
 
'Create command shell
Set WshShell = CreateObject("WScript.Shell")
 
'Uninstall previous versions of FileSite
WshShell.Run "msiexec /x {ABD11761-F3F5-421D-8726-5CCEEE333AA8} /q",1,true
WshShell.Run "msiexec /x {67F84002-C577-41C7-8F02-682A7797EE16} /q",1,true
 
'Install new version of FileSite
WshShell.Run "msiexec.exe /i ""\\archive\archive\software\Interwoven\FileSite 8.2 SP1 P3a\Full_Installer\Interwoven FileSite 8.2 SP1.msi"" /qn SERIALNUMBER=""xxxx-xxxx"" ", 1, true
 
' Map a network drive to a UNC Path and then call reg.bat which imports registry setting to collapse filesite tree when opening 
Dim oNet
Set oNet = CreateObject("WScript.Network")
oNet.MapNetworkDrive "Z:", "\\server\share"
wscript.sleep 3000
WshShell.Run ("z:\reg.bat")
wscript.sleep 5000
oNet.RemoveNetworkDrive "Z:"

Open in new window

0
 

Author Closing Comment

by:chaz21
ID: 31508480
this worked very well .  i did have to add a few wscript.sleep statements to allow the program to execute before the mapping was disconnected. thanks again for everyones input !
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Check folder every for files and print them 5 39
Excel 2016 loop through 6 43
Automatic Email Reminder 4 57
Having trouble with a VB Script 17 17
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question