I have programm running in Batch/CMD and to run it i first have to open cmd via admin, then open my programm. Is there a way to run as admin batch program without openning before cmd as admin ?
            Asked
            
        
        
            Active
            
        
            Viewed 668 times
        
    1 Answers
0
            
            
        You just need to run it with runas:
runas /user:administrator myscript.cmd
You might need to run it with /savecred
Obviously there are other switches that can be used, so running runas /? from cmd line will give the available switches.
/noprofile        specifies that the user's profile should not be loaded.
                 This causes the application to load more quickly, but
                 can cause some applications to malfunction.
/profile          specifies that the user's profile should be loaded.
                 This is the default.
/env              to use current environment instead of user's.
/netonly          use if the credentials specified are for remote
                 access only.
/savecred         to use credentials previously saved by the user.
/smartcard        use if the credentials are to be supplied from a
                 smartcard.
/user             <UserName> should be in form USER@DOMAIN or DOMAIN\USER
/showtrustlevels  displays the trust levels that can be used as arguments
                 to /trustlevel.
/trustlevel       <Level> should be one of levels enumerated
                 in /showtrustlevels.
program         command line for EXE.  See below for examples
 
    
    
        Gerhard
        
- 22,678
- 7
- 27
- 43
