Search code examples
batch-filewmic

bat file to prompt for user to input computer name


As I have to install multiple computers.....is there any way to use:

WMIC ComputerSystem where Name=COMPUTERNAME call Rename Name=NewName

but instead of "NewName" to prompt an input name....

the reason I ask, is I don't want to give same computer name to all computers, and I dont want to edit the bat file for each computer.

I'm also using:

net user username password /ADD

for this one, can I also get a prompt to insert desired user and password so I don't need to give same username and password or to edit the bat file

is there any what to automate this with users's input interaction?


Solution

  • Since it appears you want an automated way to change your PC name, this script should help you. Keep in mind you will have to reboot your PC for the effects to take place.

    For the computer name, we can automate that using a dirty method of %computername%

    @ECHO OFF
    
    SET NEWNAME=
    SET /P NEWNAME= Select a new PC name: 
    
    ::Change PC Name
    WMIC ComputerSystem where Name='%computername%' call Rename Name=%NEWNAME%
    
    CLS
    Echo Process Complete..
    Pause.
    

    Keep in mind that you can edit a remote PC on the same network using the script bellow. You can throw this in a batch file and change multiple PC's at once.

    WMIC /node:"Jon-Laptop" /user:Admin /password:password123 computersystem call rename "Jon-Tech"