rehbar Posted May 5, 2017 Posted May 5, 2017 (edited) Hello, Friends any friend tell me how to run a batch file with admin rights(run as admin) in runonce. Edited May 5, 2017 by rehbar
Tripredacus Posted May 5, 2017 Posted May 5, 2017 RunOnce will execute under the current user context at logon. Without using something else to execute the file, you will need to invoke the rights within the .cmd file itself. There is the runas command, which you can specify a different user account to run a command with, but I believe you cannot script in a password. So it would only be useful for an account in the Administrators group (or custom group with appropriate permissions) that did not have a password on it. You should look into use Task Scheduler instead. There is more freedom to setting up the condition that way. You can say, when x user logs on, run this program as this other user.
rehbar Posted May 10, 2017 Author Posted May 10, 2017 Thanks for reply. Sir my user have administrative right. now how to run a file with administrator rights.
jaclaz Posted May 12, 2017 Posted May 12, 2017 Or possibly you want this: http://code.kliu.org/misc/elevate/ jaclaz
rehbar Posted May 15, 2017 Author Posted May 15, 2017 Sir I want's to run this command with admin rights in runonce. net accounts /maxpwage:unlimited how to it possible...
R4D3 Posted May 15, 2017 Posted May 15, 2017 You can try, making a shortcut to: C:\Windows\System32\cmd.exe /c "net accounts /maxpwage:unlimited" give it adminrights, and place it in Autorun Folder... %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
Tripredacus Posted May 16, 2017 Posted May 16, 2017 You can also disable password expiry with wmic, but the command needs the user account name: wmic useraccount where "name='Support'" set PasswordExpires=false I use a command like that in a .cmd I run in FirstLogonCommands for custom deployments.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now