Are it possible to run an CMD files as Administrator as default ?

Are it possible to run an CMD files as Administrator as default ?

Darkforce_the_ilogic_guy
Advisor Advisor
575 Views
3 Replies
Message 1 of 4

Are it possible to run an CMD files as Administrator as default ?

Darkforce_the_ilogic_guy
Advisor
Advisor

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

0 Likes
Accepted solutions (1)
576 Views
3 Replies
Replies (3)
Message 2 of 4

pball
Mentor
Mentor
Accepted solution

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

 

 

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
Message 3 of 4

Darkforce_the_ilogic_guy
Advisor
Advisor

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).

 

 

 

 

 

0 Likes
Message 4 of 4

pball
Mentor
Mentor

That script automatically creates, runs, and then deletes the referenced vbs file. You do not need to do anything with that.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes