/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


How can I Elevate a command prompt to run a batch file through Scripting?

08/18/2016 8638 views
I have a batch file with some Logman commands for creating and turning on PerfMon Data counters. To run this batch file it has to be ran in a Elevated command prompt. I cannot figure out how to push these batch files in an elevated command prompt. Any ideas? I tried bundling the batch file into an .exe using iexpress and that didn't work.

Appreciate any feedback or assistance

Thanks,
Answer Summary:
0 Comments   [ + ] Show comments

Comments


Answer Chosen by the Author

2
You can run it as the system user to avoid having to deal with UAC.
Answered 08/18/2016 by: nheyne
Red Belt

  • That is how I run all of our scripts are with local system. Let me test it again just to make sure, because it still didn't work but let me confirm and reply. Thank you for your comments
  • That was it you got it. So originally I was using a template xml file that was on a network resource not open to "Everyone". I moved it but never tried the original batch file script again. Just ran into issues running the batch file from the server itself. Thank you so much for your help everything is working now.

All Answers

0
There is a really neat tool out there, just an executable that you can pair with your batch file to run them under elevated privileges.  I believe this is the link:  http://www.winability.com/elevate/

So the process in KACE would be something like:
  • Add the Elevate executable and the batch file as a dependency in the script
  • In the tasks use "Launch a program..."
  • Directory:  $(KACE_DEPENDENCY_DIR)
  • File:  Elevate_x64.exe
  • Parameters:  sample.bat

Great way to get around UAC.

Answered 08/22/2016 by: looshus
Senior Yellow Belt

0
I believe I have done this before then zipped the files up and called the shortcut. I can';t find an example on my K1000 box but it seems like I did it.

==========================================================================================

Make a batch file in an editor and nameit.bat then create a shortcut to it. Nameit.bat - shortcut. then right click on Nameit.bat - shortcut ->Properties->Shortcut tab -> Advanced and click Run as administrator. Execute it from the shortcut.


Borrowed from
http://www.howtogeek.com/forum/topic/make-a-batch-file-to-run-cmd-as-administrator
Answered 08/18/2016 by: rockhead44
Red Belt

  • So, is there any way to force it to hit yes to a UAC prompt once ran? Most of our servers still have UAC enabled and disabling it on all of them will be a whole other issue for us.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ