0

I have a simple startup.cmd script which runs some net commands to create a new user and add the user to the administrator group.

I got the script from this blog. I have run the net commands in a elevated CMD session and they work correctly. but running this on my developer machine just sees the role hanging.

Is there some trick i'm missing?

startup.cmd file contents: net user dataAdmin thepassword /add net localgroup Administrators dataAdmin /add

the relevant snippet from the servicedefinition file:

the startup.cmd is set to build action = Content and Copy Always for the copy to output directory

I haven't tried this in azure production yet. I will attempt to push it into staging later today.

UPDATE At BStateham's suggestion I checked the event logs on my machine: Under 'Windows Azure' there is a error logged:

User program "..\SLC.DataRole\approot\bin\startup.cmd" exited with non-zero exit code 1

Any idea what that is supposed to mean?

Community
  • 1
  • 1
Andrew Harry
  • 13,773
  • 18
  • 67
  • 102
  • Have you looked in the compute emulator for your instance? Any information in the log there? – BStateham Dec 12 '12 at 01:01
  • in the event logs - User program "F:\Projects\SLC\Database\SLC.AzureProject\csx\Debug\roles\SLC.DataRole\approot\bin\startup.cmd" exited with non-zero exit code 1 – Andrew Harry Dec 12 '12 at 01:06
  • It's possible that it is failing on your dev box because the account already exists. You might create a Pre-Build or Post-Build script in your project that deletes the user account prior to running the project on the local dev box. – BStateham Dec 12 '12 at 01:07
  • I check to make sure of this. The new account has not being made so far via this script (only manually via cmd - which I then removed) – Andrew Harry Dec 12 '12 at 01:08
  • I'm getting similar behavior. However, if I modify the startup task to not include the "net *" commands, it runs. Feels like a permissions issue to me. Is your developer machine domain joined? – BStateham Dec 12 '12 at 01:33
  • getting somewhere. there was a stupid text encoding issue. saved as ansi encoding and working now. also need to pick a shorter password to avoid a confirmation prompt – Andrew Harry Dec 12 '12 at 01:37
  • I got mine working as well. Problem was I was using your script with "thepassword" as dataAdmin's password. My machine policy was preventing that. It works now for me. Let me know if you continue to have problems. – BStateham Dec 12 '12 at 01:45
  • My azure machine has changed the default password policy to require complexity - broke my site without warning! – Andrew Harry Jun 27 '13 at 14:30

1 Answers1

1

Based on your comments it looks like you discovered this but a critical requirement is that the startup cmd file has the correct encoding, and

"Be sure to create it with notepad or another ASCII text editor… batch files created in Visual Studio seem to have a byte order mark at the top that makes them fail when executed."

Also this and this this are good references for some other common issues with startup commands.

Rory
  • 40,559
  • 52
  • 175
  • 261