I am trying to run a batch script that has to be run from an elevated command prompt. I know I have done this before, but I can't seem to get it to work now. It is set up as an online kscript with Run as User checked and the administrator credentials are provided. When I run the script, it does not complete. If I go into the dependency directory and right click the batch file and hit run as administrator, it runs fine.

Answer Summary:
Cancel
4 Comments   [ + ] Show Comments

Comments

  • are you using the runas command?

    Runas (place username and password) (xxx.bat)
    • No, I thought that if I used the run as user in the KScript and put in administrator credentials, that it would elevate it.
      • Can you do a screen shot of the script?
        Also if you can post your batch, they may be a more direct method to calling what you are trying to do.

        Note: I have had to switch to calling cmd.exe as the program to run with 3.5 and put the batch file in the parameters with some things.

        you would Launch c:\windows\system32\cmd.exe with params /c my.bat
  • This content is currently hidden from public view.
    Reason: Removed by member request
    For more information, visit our FAQ's.
  • This content is currently hidden from public view.
    Reason: Removed by member request
    For more information, visit our FAQ's.
  • I added a screen shot that I am working from right now.
  • I will try using the launch and see what happens.
  • Still a no go from KACE, but like I said, if I run any of these options locally on the computer,it works.
Please log in to comment

Answers

0

You can also add psexec as a dependancy and run that way

psexec -u user -p password batfile.bat

Answered 01/09/2014 by: SMal.tmcc
Red Belt

Please log in to comment
0

try this

 

Answered 01/09/2014 by: SMal.tmcc
Red Belt

  • When I tried that, the script failed with the message that it could not find the file specified.
Please log in to comment
0

OK, no matter what I tried, I could not get it to run. It seems that when KACE calls the script it uses the command prompt that is in SYSWOW64 instead of System32. The file I need to call was in the system32 folder. 

I added bcdedit as a dependency to the script and it is working now.

Answered 01/10/2014 by: WGM_Jeff
Fourth Degree Black Belt

  • good to hear

    I have been trying to use the steps I would put in a batch file as lines in scripts and have had lots more success. I usually use the dos paths to call the exe's instead of a variable for that reason. a couple of exe's have both 32 and 64 copies in the OS and if you do not call the proper version things do not happen as they should sometimes. the fall back is sometimes I have to create a 32 and 64 bit script to do the same thing.
Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share