Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating bat file that requires user input

Status
Not open for further replies.

mholbert

IS-IT--Management
Jan 10, 2006
105
US
I am trying to build a bat file to automate the process of renaming a network computer. I can use the netdom utility included in the xpsp2 support tools to accomplish this, but I would like to tweak the basic command to allow me to enter the 'old computer' and 'new computer' names when I run the bat file.

Here is the command

netdom renamecomputer machine /newname:new_computername /userd:domainname\administrator_id /passwordd:* /usero:local_admin
/passwordo:* /reboot:seconds before automatic reboot

any help is appreciated. MH
 
Batch files cannot really recieve user input. you could however call the batch file with a parameter which would possibly acomplish the same thing.
so for example:
Code:
C:\>mybatch.bat parmaeter1 paramter2 ....

You would access the parameters inside suing the numbered vcariables. So the first [parameter would be in %1 the second parameter would be in %2. etc...

Code:
echo %1
echo %2
etc..

You could then call your batch file and [pass the names of the computer to it.


Code:
mybatch oldname newname

and substitute inside the proper params.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
both look like good solutions.

thanks, MH
 
First, another stupid question. How do you mark something as 'code' in you posts?

Regarding my original question. I did a little more research and came up with the following.

The following uses netdom to rename a computer of your choosing on your network. You would want to first populate the appropriate network username/password in the script, and then populate the old name/new name stuff at run time.

Thanks for the suggestions, it got me looking until I found what I wanted.

CODE
@Echo This will rename a computer on the network

@echo off

set CurrentName=
set /p CurrentName=Type Current Name...
set NewName=
set /p NewName=Type New Name...


cd "c:\program files\support tools"
netdom renamecomputer %CurrentName% /newname:%NewName% /userd:DOMAIN\USERNAME /passwordd:pASSWORD /usero:DOMAIN\USERNAME /passwordo:pASSWORD /reboot:10"

pause

 
Code:
some code


____________________________
Users Helping Users
 
InputBox 1.1
01/31/03 Free inpbox11.zip
(224 Kb)
"Console mode program that allows you to prompt users for input using a standard Windows input box, then write that input into a file. Makes for a user friendly way of inserting real-time data into batch, registry, INI, or other text files. When you have to ask for input during a batch process, InputBox is what you need."


Batch parameter
thread779-279482
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top