Batch files running on startup - Not running synchronously.
Moderator: DosItHelp
Re: Batch files running on startup - Not running synchronous
What syntax or operational error does it produce in a batch file?
Re: Batch files running on startup - Not running synchronous
Cancerous wrote:Soooo I figured out what is most likely the issue.
Netdom won't run from the .bat file, but will run if I type it directly in to the shell. Any ideas as to why this happens?
To use netdom, you must run the netdom command from an elevated command prompt.
Re: Batch files running on startup - Not running synchronous
EDIT: This didn't work!
I did solve it a differnet way though. I ditched wsname and instead declared the computername inside the unattend.xml, there was a reason I wasn't doing this in the first place, but our requirements have changed so now I can do it. I also added the netdom script to the xml file as a FirstLogonCommand, along with the domain credentials in the specialize fase. I'm not entirely sure which one is joining the domain, but it works so I'm not going to test it any more.
Finally solved it.
For some reason the IF EXIST check doesn't work with netdom, so I just made the netdom script a one liner.Code: Select all
netdom join %computername% /Domain:XXX /UserD:XXX /PasswordD:XXX /REBoot
It looks incorrect (logically), but it works!
So for anyone who sees this later, here's my two sscript files that I've added to gpedit to run on startup.
changename.batCode: Select all
@echo off
IF NOT EXIST c:\wsnameran.flag c:\wsname.exe /N:$SERIALNUM /REBOOT ; echo.> c:\wsnameran.flag
joindomain.batCode: Select all
netdom join %computername% /Domain:XXX /UserD:XXX /PasswordD:XXX /REBoot
I did solve it a differnet way though. I ditched wsname and instead declared the computername inside the unattend.xml, there was a reason I wasn't doing this in the first place, but our requirements have changed so now I can do it. I also added the netdom script to the xml file as a FirstLogonCommand, along with the domain credentials in the specialize fase. I'm not entirely sure which one is joining the domain, but it works so I'm not going to test it any more.