I'm pulling computer names from a text file, changing the names to a new name, and trying to log any errors in a separate text file, using a batch command. However, I don't know how to run an if statment that tests the netdom command. Here is the relevant code:
FOR /F "skip=2 tokens=1,2" %%1 IN (rendompc.txt) DO (
netdom renamecomputer %%1 /newname:%%2 /userD:secondary.frontier\administrator /passwordD:Password
/userO:secondary.frontier\administrator /passwordO:Password /verbose>test.txt /force /reboot:30
if errorlevel 1 echo %%1 %%2 FAIL >>computernamechange.txt
)
How can I log that error or test for fail?
|