I'm using the WMIC cmd to rename a local user in WinXP. I want to create a batch to run the below cmd line, but allow to enter variable of newusername. wmic useraccount where name='user'call rename name='newusername'
wmic useraccount where name='%1'call rename name='%2' or if you want prompts:
@echo off & setlocal
set /p user=currentusername:
set /p newusername=new username:
wmic useraccount where name='%user%'call rename name='%newusername%'
Thank you for your prompt reply; but I have tried this before in several different ways and got the below error: ERROR:
Code = 0x80041017
description = Invalid query
Facility = WMII thought that it might be a syntax issue, but I'm not sure.
I assume that you have already ensured that everything is working before running the script. if not you might consider running this to check: http://www.microsoft.com/downloads/...
Just in case its not the coding.
:: mike
yeh, I just used your exact syntax, and we're both running xp, and mine worked.
i did notice this however:
wmic useraccount where name='user'call rename name='newusername'having no space between 'user' and call, generated "invalid inquiry".
try this:
wmic useraccount where name='%1' call rename name='%2'(apologies for my former post: i cut/pasted your code, hence it still contained the error of no space).
