VBScript question

DVAmon

2[H]4U
Joined
Aug 14, 2003
Messages
2,282
Hey all,

I don't know if the scripting stuff counts as programming but I figure I'd give this a shot:

I don't know vbscript well, and I was trying to write a CMD batch file to accomplish a particular function, which was using the netsh command to create a batch file that a tech in the field will use to supply a machine with a static IP address.

I wasn't able to find a way to allow the batch file to let the tech interact with it. One of my friend suggested I use vbscript to accomplish this, but I don't know how to begin. I have a book here that I picked up, and I've been checking the sites and such to learn it, but I haven't found a way to take the input using an inputbox to then output it to a variable which I can then call later to take the place of the addr="static IP address subnet mask default gateway" that I need for the netsh portion to configure the LAN with a manual address. I can probably figure out how to set my objects and such for that portion, but the main issue is grabbing that output.

I'm not asking anyone to write it for me, but to help me understand what I'm doing so I can write it myself. If anyone has a good vbscript resource, flash movie, etc. that would be great. In the interim I will read the book and practice some basic things till I get a better handle on this.

Thanks in advance for any assistance
-Dave
 
Well here's the thing, since I'm trying to automate it, I'd like it to just run by double clicking the VBS file. Unfortunately the parser used for the STDIN is using cscript, which fails unless invoked from the cscript> prompt within the CMD.

What I'm basically trying to find out if there is a way to use an InputBox function, then to copy or redirect the input to a variable that I can call as an output later when I actually try to run the netsh command.

Appreciate all the help so far
 
When using the InputBox you are assigning it a variable to use right from the get go. Here is an example to have it prompt you for the IP address:

strIPAddress = InputBox("Enter the IP address to assign to the computer.", "Assign IP Address.")

"strIPAddress" is the variable name which can be named anything you want. "InputBox" is the vbscript code to call it up. "Enter the IP address to assign to the computer." is the text that shows up in the body of the input box popup. "Assign IP Address." is the title bar text of the popup.

From this point you would be able to use the "strIPAddress" variable any where else in the rest of your code and its value will be whatever you enter in when it prompts you.

Here is a great site to browse if you haven't been here already: http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true

And if you want some material on VBScript I would suggest a book called Advanced VBScript for Microsoft Windows Administrators. Don't let the "advanced" title fool you the book examples are very well explained.
 
thanks, now I just have to figure out how to declare the object to call the netsh and use the syntax. I haven't been to that MS link, so that should prove helpful.

Thanks a lot, I'll post the code once I get it working in case someone else might need it in the future.
 
Well, my suggestion would be to use the true vbscript code for your operation. With the link I posted above, go to the Networking section, then Client Side Management, Configuring Network Settings, Assign a Static IP.

That will be a nice start for your program.
 
Back
Top