# VB Scripting help por favor

**URL:** <https://boards.straightdope.com/t/vb-scripting-help-por-favor/214548>\
**Category:** Factual Questions\
**Created:** [November 21, 2003, 6:21pm UTC](https://boards.straightdope.com/t/vb-scripting-help-por-favor/214548 "2003-11-21T18:21:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SlickRoenick](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@SlickRoenick](https://boards.straightdope.com/u/SlickRoenick)\
**Post date:** [November 21, 2003, 6:21pm UTC](https://boards.straightdope.com/t/vb-scripting-help-por-favor/214548/1 "2003-11-21T18:21:26Z")

</div>

Here’s the code:

> [@](#):
>
> set ryan= WScript.createobject(“wscript.shell”)
> 
> ryan.run “net use s: \myserver1\c$” & \_  
> “net use t: \myserver2\c$”

All I am trying to do is map 2 network drives in 1 command shell but it only maps the first one. Anyone know how to do what i’m trying to do?

---

<div class="post-metadata">

**Author:** ![magog](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@magog](https://boards.straightdope.com/u/magog)\
**Post date:** [November 21, 2003, 6:28pm UTC](https://boards.straightdope.com/t/vb-scripting-help-por-favor/214548/2 "2003-11-21T18:28:04Z")

</div>

Try this:

set ryan= WScript.createobject(“wscript.shell”)  
ryan.run “net use s: \myserver1\c$”  
ryan.run “net use t: \myserver2\c$”

Also not sure if you should dispose your object using  
set ryan = Nothing

---

<div class="post-metadata">

**Author:** ![SlickRoenick](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@SlickRoenick](https://boards.straightdope.com/u/SlickRoenick)\
**Post date:** [November 21, 2003, 6:29pm UTC](https://boards.straightdope.com/t/vb-scripting-help-por-favor/214548/3 "2003-11-21T18:29:51Z")

</div>

Understood. However, can it be done by only opening 1 shell instead of 2?

---

<div class="post-metadata">

**Author:** ![davidm](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/davidm/32/225_2.png) [@davidm](https://boards.straightdope.com/u/davidm)\
**Post date:** [November 21, 2003, 7:03pm UTC](https://boards.straightdope.com/t/vb-scripting-help-por-favor/214548/4 "2003-11-21T19:03:06Z")

</div>

> [@](#):
>
> \*Originally posted by SlickRoenick \*  
> \*\*Understood. However, can it be done by only opening 1 shell instead of 2? \*\*

I’m not really familiar with the wscript.shell object but you could try putting a carriage return in the string between the two net use commands. Alternatively, you could put the net use commands in a batch file and give ryan.run a string with the name of the batch file. Also, **magog** is correct that you should set the object to nothing when you’re done with it, but you may already know that.

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [November 21, 2003, 11:50pm UTC](https://boards.straightdope.com/t/vb-scripting-help-por-favor/214548/5 "2003-11-21T23:50:57Z")

</div>

wscript shell can only handle one command item per invocation. You can, as davidm sez, make a batch file and invoke that via the wscript.shell.run method Or, you can use cmd.exe, which DOES support multiple commands in one invocation. Try something like this:

```auto

set ryan= WScript.createobject("wscript.shell")
ryan.run "cmd.exe /c net use s: \\myserver1\c$ & net use t: \\myserver2\c$"
set ryan = Nothing

```

Note the & character is inside the string, not used to concatenate two strings. If this doesn’t work the first time, try enclosing each net use command in (), like this:

```auto

set ryan= WScript.createobject("wscript.shell")
ryan.run "cmd.exe /c (net use s: \\myserver1\c$) & (net use t: \\myserver2\c$)"
set ryan = Nothing

```

Sometimes cmd’s parser gets lost and needs a little help.

This will create an extra cmd.exe window while its trunning, but that’s only visible for a moment.
