Logging netdom errors

October 23, 2009 at 13:14:42
Specs: Windows XP
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?

See More: Logging netdom errors

Report •

October 23, 2009 at 14:44:10
if errorlevel 1 echo %%1 %%2 FAIL >>computernamechange.txt
If this doesn't work, you'll probably have to parse STDERR in some fashion.

Report •
Related Solutions

Ask Question