- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am working on an system that would make it possible to full an new standard setup to the user in sekund. I might be able to do it fullautomation. but I would like to come it possible for the users to control it... but the cmd I have program need to be run as Admin .... it is possible to do that local if you know how ... but i would like to double click the files wait 2 sekunden and now you have all the update to your setting.
today I have a lot of running around form computer to computer. If I make an change .. like add new special design tool , VBA code , and Copy design rules... or give the users speciel setup search to My Search Folders
is there a way to do that
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm not aware of a way to make cmd files run as admin by default. But there is a trick to have a cmd file run it self as admin.
The code below will create a temporary vbs script that will run the cmd file with admin permissions. You just have to add your code to the payload section where noted.
@Anonymous off
if _%1_==_payload_ goto :payload
:getadmin
echo %~nx0: elevating self
set vbs=%temp%\getadmin.vbs
echo Set UAC = CreateObject^("Shell.Application"^) >> "%vbs%"
echo UAC.ShellExecute "%~s0", "payload %~sdp0 %*", "", "runas", 1 >> "%vbs%"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
goto :eof
:payload
echo %~nx0: running payload with parameters:
echo %*
echo ---------------------------------------------------
cd /d %2
shift
shift
echo PUT YOUR CODE HERE
goto :eof
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am not sure I understand your code very well.
Do I not missing somthing ?
it seens to me that I would need an file call
%temp%\getadmin.vbs
I do not have it ... does your code not delete this file ,after first time use?
I know a liltte programming ... but I am no master at all..so it may only be a lag of skill form my part .
but you are right on one thing.. I only need to get that one files to run as administrator(admin).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
That script automatically creates, runs, and then deletes the referenced vbs file. You do not need to do anything with that.