使用 wmic 时 bat 文件错误 "invalid verb switch"

bat file Error "invalid verb switch" when using wmic

大家好,我需要一些帮助,我是 bat 文件的新手,我收到了这个错误 "invalid verb switch" 我不明白为什么? 我只想用 %newusername%

重命名当前用户

我在网上看过,一切都一样,有什么想法吗?

@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

这最终解决了我的错误:

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

看来我缺少 callname= 选项。