How can I Elevate a command prompt to run a batch file through Scripting?
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.
Thanks,
Appreciate any feedback or assistance
Thanks,
0 Comments
[ + ] Show comments
Answers (3)
Answer Summary:
Please log in to answer
Posted by:
nheyne
8 years ago
Top Answer
You can run it as the system user to avoid having to deal with UAC.
Comments:
-
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 - dgaliffa90 8 years ago
-
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. - dgaliffa90 8 years ago
Posted by:
looshus
8 years ago
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:
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.
Posted by:
rockhead44
8 years ago
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
Comments:
-
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. - dgaliffa90 8 years ago
-
Not sure on that one - rockhead44 8 years ago