Batch files running on startup - Not running synchronously.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch files running on startup - Not running synchronous

#16 Post by foxidrive » 16 Oct 2012 02:14

What syntax or operational error does it produce in a batch file?

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Batch files running on startup - Not running synchronous

#17 Post by Squashman » 16 Oct 2012 05:45

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.

Cancerous
Posts: 9
Joined: 11 Oct 2012 16:55

Re: Batch files running on startup - Not running synchronous

#18 Post by Cancerous » 17 Oct 2012 19:54

EDIT: This didn't work!
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.bat

Code: Select all

@echo off
IF NOT EXIST c:\wsnameran.flag c:\wsname.exe /N:$SERIALNUM /REBOOT ; echo.> c:\wsnameran.flag


joindomain.bat

Code: 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.

Post Reply