How to pass a variable to a WMI query run in a batch file?

0

1

I want to run the following in a batch file and prompt the user to enter "NewUserID", then insert it as a variable. Can this be done with WMI?

wmic useraccount where name='user'call rename name='NewUserID'

Dianda

Posted 2012-11-15T19:43:18.373

Reputation: 1

Answers

0

why not prompt the user with set /p I did this with some HP machines to read the AssetTag field fom the BIOS.

You should be able to replace newuserid with your variable.

Test

Start a bat or cmd file.

@echo off
set /p _MYVARIABLE=
echo %_MYVARIABLE%
pause

I found a reference to wmic and they discuss variables with this command. Link

TheSavo

Posted 2012-11-15T19:43:18.373

Reputation: 364

I tried it and got the following error msg: Code:=0x80041017 Description=Invalide query, Facility=WMI – Dianda – 2012-11-15T20:33:01.317