Bat file Error “invalid verb switch” when using wmic

batch-filewmic

Hey guys i need some help i am a total noob to bat files i am getting this error "invalid verb switch" I dont understand why?
All i am wanting to do is rename the current user with %newusername%

I have looked on line and everything seams to be the same any thoughts?

@echo off
    for /F "tokens=4 delims=.:" %%G in (
        'ping -4 %COMPUTERNAME%^|find "Reply from"'
    ) do set "IP=%%G"
    set "ipadd=%IP:~-3%"


set mydate=%date:~4,2%%date:~7,2%%date:~10,4%
set /p pathName=Employees Name:%=%
set /p store=Store prefix (ie: rfl, rac, rca, rdcjr):%=%
set /p location=location (ie: salesflrN1, partsNE2):%=%
echo. 
echo.
echo ip address: %last3digits%
set newusername=%store%.%ipadd%-%pathName%
echo New User Name Will Be: %newusername%
echo. 
echo ___________________________________________________________________________
echo ***************************************************************************
echo ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
echo. 
echo By Pressing enter you will be performing the following actions....
echo.
echo 1. Updating The computers name to: ******* 
echo 2. Updating The computers User Name to: ******* 
echo 3. And You Will Be Forceing A System Reboot: ******* 
echo.
echo 3. Press "Enter" To Continew Or Alt+F4 To Exit 
echo.
echo ___________________________________________________________________________
echo ***************************************************************************
echo ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
pause
wmic useraccount where name='%username%' rename %newusername%
pause

Best Answer

This ended up fixing my error:

wmic useraccount where name='%USERNAME%' call rename name='%newusername%'
net.exe user "%newusername%" /fullname:"%newusername%" 

Looks like I was missing the call and name= option.

Related Topic