1

I have a batch file which contains below code:

runas /user:Administrator "C:\Test.bat"

When i'm running this file it asks for Password so if in case i give incorrect password it directly terminates but i want to handle this error. It should not terminate directly.

Roshan007
  • 658
  • 2
  • 7
  • 15

1 Answers1

1

you can do it in a loop:

:loop
runas /user:Administrator "C:\Test.bat" || goto :loop

As long as runas fails (for example because of a wrong password), it will try again.

Stephan
  • 53,940
  • 10
  • 58
  • 91