0

I have a repetitive testing task I need to do, which I'm hoping to automate. Unfortunately, part of the testing procedure involves creating a new Windows user account, then logging in as the new account to continue testing. I'm fairly sure I can create the new account, but I can't find a way to automate changing user and continuing execution of a bat script. I've found the tsdiscon and tscon commands for quickly switching user, but as I understand it, tscon only works if the account being switched to is already logged in, which doesn't help when the account is brand new.

I found this question regarding resuming bat file execution after a reboot, which is going to be very useful, but multi-user automation seems to be a much harder problem.

Tam Coton
  • 786
  • 1
  • 9
  • 20

1 Answers1

1

You could use the net user command to create a new local user account and then use the runas command to execute a program, batch script, or command with the permissions of the newly created user.

If you want to open a desktop session for the new user, you could change the DefaultUserName and AutoAdminLogon registry key values and then initiate a reboot. The following SuperUser topic might be useful to you: Automatic logon

303
  • 2,417
  • 1
  • 11
  • 25