日期:2014-05-17 浏览次数:20849 次
Re=1 Set objWMIService = GetObject("Winmgmts:root\cimv2") For Each objComputer in objWMIService.InstancesOf("Win32_ComputerSystem") Cn=objComputer.Name Next For Each objComputer in objWMIService.InstancesOf("Win32_UserAccount") If objComputer.Name="test" Then Re=objComputer.Rename(Cn) End If Next If Re<>0 then WScript.Echo "操作失败!" Else WScript.Echo "操作成功!" End If
------解决方案--------------------
方法1
@echo off set OldName=learnlife for /f "delims=" %%a in ('hostname') do ( wmic useraccount where name='%OldName%' call rename "%%a" )