none
Running CMD as administrator RRS feed

  • Question

  • Ok, this is basic grade school stuff but I haven't figured it out.

    I have a batch file in my image that I want to run during the TS at the desktop. I'd like to use the cmd step in my TS but the file has to be in system32 and needs admin authority.
    All I need is the syntax for the "Command line" to use cmd.

    Would that be: cmd.exe /c "runas /user:administrator C:\path to file" ? If so, do I also need credentials typed out in my TS?

    Thanks!

    Tuesday, January 10, 2017 2:22 PM

Answers

  • The tasks in a task sequence are already being run as Administrator so you shouldn't need to do anything but the following:

    cmd.exe /c "Batch file"

    There is however a check box to "Run this step as the following account" and you can set a specific account including the password. But you shouldn't need to use that.

    You might want to try:

    cmd.exe /k "batch file"

    In case your batch file needs time to run things, then have your batch file run exit at the end to terminate the command prompt.


    If this post is helpful please vote it as Helpful or click Mark for answer.

    • Marked as answer by the1rickster Tuesday, January 17, 2017 11:59 PM
    Tuesday, January 10, 2017 3:04 PM

All replies

  • The tasks in a task sequence are already being run as Administrator so you shouldn't need to do anything but the following:

    cmd.exe /c "Batch file"

    There is however a check box to "Run this step as the following account" and you can set a specific account including the password. But you shouldn't need to use that.

    You might want to try:

    cmd.exe /k "batch file"

    In case your batch file needs time to run things, then have your batch file run exit at the end to terminate the command prompt.


    If this post is helpful please vote it as Helpful or click Mark for answer.

    • Marked as answer by the1rickster Tuesday, January 17, 2017 11:59 PM
    Tuesday, January 10, 2017 3:04 PM
  • Yes of course. I don't know why I felt I had to run it as admin....probably because manually running it on a machine would only work if right-clicking as admin. Derrr.
    Tuesday, January 17, 2017 11:59 PM