Sign in to follow this  
Followers 0
dexter

Run as admin in Windows 7

15 posts in this topic

Hi ! As a part of my program, I need to temporarily disable password prompt on wakeup option and at the end, re enable it. It works fine in case of Xp. But in Windows 7, I get error like you dont have required permission. please guide me. I m using a power config command using _runDos.

Share this post


Link to post
Share on other sites



Check the help file for the #RequireAdmin function.

Share this post


Link to post
Share on other sites

Thanks Raven, that will solve my issue to an extent ... I found a cmd script that can be used to enable and disable password prompt in Windows 7 , but it needs to be run as an admin ( which is fine now with #RequireAdmin function) and is to be run in elevated cmd ... The normal _runDos runs in cmd, which havnt got privilege to make changes,the elevated cmd has to be launched from system32\cmd.exe; else when ever we just start from run, it runs from user directory with lesser privileges.

I can use run to launch the cmd.exe file from system32, but how will I enter this -

"powercfg -SETDCVALUEINDEX SCHEME_BALANCED SUB_NONE CONSOLELOCK 0" ?

I dont want to use keystroke simulation, since there is no guarantee that the GUI will be at the top.

P.S. Plz clarify if runDos runs scripts on windows 7 under normal cmd or the elevated cmd.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

RunDos() will run the prompt under whatever security token the script currently has. If your script is admin, programs it runs will be admin as well.

Edited by Richard Robertson

Share this post


Link to post
Share on other sites

RunDos() will run the prompt under whatever security token the script currently has. If your script is admin, programs it runs will be admin as well.

No brother, I have checked that. Yes, #requireadmin is making it run with admin privileges, but those commands can only be executed from elevated cmd, RunDos runs only the normal cmd. I can start elevated cmd using run via system32 directory. But how do I pass those commands ? And I dont want the cmd window to be visible to the user.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Have you tried this?

#RequireAdmin
;...
RunWait("powercfg -SETDCVALUEINDEX SCHEME_BALANCED SUB_NONE CONSOLELOCK 0", "", @SW_HIDE)
Edited by Richard Robertson

Share this post


Link to post
Share on other sites

Thanks a lot Richard, it worked just fine ... Thanks a lot again, you made my day !

Share this post


Link to post
Share on other sites

You're welcome.

Share this post


Link to post
Share on other sites

Richard that works great --but how do i do the same -but not have to click on the OK yes button to approve to run as admin. I need this to run and stop my service without being there (actually i will be sleeping-i hope) I am looking to stop a service so i can back up the files then restart the same service after my back up. --my back up program can run a script before and after the back up. so all i need to do is create 2 compiled script to run one to start and one to stop.

is there an continuation of your script above that will auto key troke the yes click? or another script that can run with admin privileges.

thanks

Rob

Share this post


Link to post
Share on other sites

No. If UAC is active, you must allow at least one program to run as admin by physically clicking the button.

Share this post


Link to post
Share on other sites

thanks

then how can you click on the stop button in services window in windows and the service stops without asking? I would think we could do the same?

rob

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

with either admin user or administrator(windows) do youhave to have a password or can it be blank ( "" ),

using Runas what do you use as domain if you are on a workgroup ("MSHOME"). do you replace DomainName with ComputerName if only local?

Rob

Edited by Twixxct

Share this post


Link to post
Share on other sites

Services are already running under the system account and have administrative access. You must be an administrator to set up the service in the first place.

Share this post


Link to post
Share on other sites

I see, thanks

Share this post


Link to post
Share on other sites

You can use scheduled tasks to start an application as administrator without being prompted every time:

http://www.howtogeek.com/howto/windows-vista/create-administrator-mode-shortcuts-without-uac-prompts-in-windows-vista/

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0