Discussion:
How to use variables to map network drive
(too old to reply)
notsomuchscripting
2009-05-14 18:45:17 UTC
Permalink
I want to ask the user to input the IP address of the server so that we
can use this script at multiple sites. Also, I want the user to pick
which open network drive they want to use.

<code>
dim answer
IP=InputBox("What is the NBO server IP Address:")

Drive=InputBox("What drive letter would you like to use for your
install scripts?")

Set objNetwork = CreateObject("WScript.Network")

objNetwork.MapNetworkDrive Drive , Drive, "\\" IP "\data\zdm\apps"
</code>
--
notsomuchscripting
------------------------------------------------------------------------
notsomuchscripting's Profile: http://forums.techarena.in/members/98512.htm
View this thread: http://forums.techarena.in/server-scripting/1180247.htm

http://forums.techarena.in
T Lavedas
2009-05-14 20:02:33 UTC
Permalink
On May 14, 2:45 pm, notsomuchscripting <notsomuchscripting.
Post by notsomuchscripting
I want to ask the user to input the IP address of the server so that we
can use this script at multiple sites. Also, I want the user to pick
which open network drive they want to use.
<code>
dim answer
IP=InputBox("What is the NBO server IP Address:")
Drive=InputBox("What drive letter would you like to use for your
install scripts?")
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive Drive , Drive, "\\" IP "\data\zdm\apps"
</code>
--
notsomuchscripting
------------------------------------------------------------------------
notsomuchscripting's Profile:http://forums.techarena.in/members/98512.htm
View this thread:http://forums.techarena.in/server-scripting/1180247.htm
http://forums.techarena.in
Change ...

objNetwork.MapNetworkDrive Drive , Drive, "\\" IP "\data\zdm\apps"

to ...

objNetwork.MapNetworkDrive Drive, "\\" & IP & "\data\zdm\apps"

This presumes the user has entered the drive letter followed by a
colon. This may be problematic. Also, I presume there are a limited
number of IP addresses that can be used. Making the user enter the
entire IP address will probably be error prone. Therefore, I'd
suggest you hard code the possible IP selections and off the user a
menu from which to select. The simplest just uses the InputBox with a
longer prompt string, something like this ...

aIPAddresses = Array("A). 123.1.2.456", "B). 123.1.2.789", "C).
234.2.3.123")

IP=InputBox("Select the NBO server IP Address:" & vbCRLF & Join
(aIPAddresses, vbCRLF)

The more user friendly approach would be to create a dialog box using
IE and provide drop down selections, but that's beyound the scope of
what you asked.

BTW, the WSH documentation might be helpful for things like this ...

WSH 5.6 documentation download (URL all one line)
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

Tom Lavedas
***********
Al Dunbar
2009-05-14 23:07:12 UTC
Permalink
"T Lavedas" <***@cox.net> wrote in message news:0ff91581-31c3-4078-85e9-***@g20g2000vba.googlegroups.com...
On May 14, 2:45 pm, notsomuchscripting <notsomuchscripting.
Post by notsomuchscripting
I want to ask the user to input the IP address of the server so that we
can use this script at multiple sites. Also, I want the user to pick
which open network drive they want to use.
<code>
dim answer
IP=InputBox("What is the NBO server IP Address:")
Drive=InputBox("What drive letter would you like to use for your
install scripts?")
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive Drive , Drive, "\\" IP "\data\zdm\apps"
</code>
--
notsomuchscripting
------------------------------------------------------------------------
notsomuchscripting's Profile:http://forums.techarena.in/members/98512.htm
View this thread:http://forums.techarena.in/server-scripting/1180247.htm
http://forums.techarena.in
Change ...

objNetwork.MapNetworkDrive Drive , Drive, "\\" IP "\data\zdm\apps"

to ...

objNetwork.MapNetworkDrive Drive, "\\" & IP & "\data\zdm\apps"

This presumes the user has entered the drive letter followed by a
colon. This may be problematic. Also, I presume there are a limited
number of IP addresses that can be used. Making the user enter the
entire IP address will probably be error prone. Therefore, I'd
suggest you hard code the possible IP selections and off the user a
menu from which to select. The simplest just uses the InputBox with a
longer prompt string, something like this ...

aIPAddresses = Array("A). 123.1.2.456", "B). 123.1.2.789", "C).
234.2.3.123")

IP=InputBox("Select the NBO server IP Address:" & vbCRLF & Join
(aIPAddresses, vbCRLF)

The more user friendly approach would be to create a dialog box using
IE and provide drop down selections, but that's beyound the scope of
what you asked.

BTW, the WSH documentation might be helpful for things like this ...

WSH 5.6 documentation download (URL all one line)
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

Tom Lavedas
***********

===================

Why IP address rather than server name?

/Al

Loading...