Script Center >
Scripting Forums
>
The Official Scripting Guys Forum!
>
How to run VBScript with local administrator permissions
How to run VBScript with local administrator permissions
- How to run the following script with local administrator permissions?
Set oShell = CreateObject("Wscript.Shell")
test = "CMD /c POWERCFG /X " & Chr(34)&"Alltid på"&Chr(34) & " /monitor-timeout-ac 0"
oshell.Run test, 0
I have tryed with an GPO but it only works if the user is admin:(- Edited bytp_tp Tuesday, August 25, 2009 9:24 AM
Answers
I solved the problem by making the changes in registry with a VBScript.
Made a .exe of the script that runs automaticly as an Domain User With Admin Rights.
It makes changes in HKU insted of HKCU.- Marked As Answer bytp_tp Friday, September 04, 2009 9:14 PM
All Replies
- You could use it with a GPO if you run it as a startup script under computer configuration instead of a logon script under user configuration.
Startup scripts run under the local system account which has administrative rights. - If you apply GPO to Mashne policy, then script will runing as SYSTEM account.
or you can usage
Set oShell = CreateObject("Wscript.Shell")
test = "runas /user:wcfc\testuser cmd < input.txt"
oshell.Run test, 0
where input.txt - i's file whis password.- i tryd to run it under computer configuration but it din´t work at all.
Is thera a way to give users permission to powercfg.exe with a GPO, can that help? - do i need to have the password in an tex file?
You could use it with a GPO if you run it as a startup script under computer configuration instead of a logon script under user configuration.
Startup scripts run under the local system account which has administrative rights.
It das't work under computer configuration, It writes to HLCU and must therfore be rur as an logon script.
It wont work to run the script as an local admin because then the chanes will e made in local admins HKCU(profile) and not the logged on users profile.
How can I make this work?- Hi tp_tp,
What operating system are you trying to make this work on?
Bill Hi tp_tp,
What operating system are you trying to make this work on?
Bill
Im trying to do it on XP klients.
Im trying to modify and create keys under HKEY_CURRENT_USER\Control Panel\PowerCfg.- Hi tp_tp,
That's what I expected you to say...I don't have a good answer other than to use a power management tool such as EZ_GPO.
Regards,
Bill Hi tp_tp,
That's what I expected you to say...I don't have a good answer other than to use a power management tool such as EZ_GPO.
Regards,
Bill
i have tryed to use EZ_GPO but it dont work on our klients.
get som error on login.
EZ_GPO is nor an option!- Sorry tp_tp, EZ_GPO is the only (free) way, that I know of, to do power management configuration through a GPO for XP clients (at least with a Server 2003 domain). I don't know what "some error on login" means, but I have found they do read and respond to trouble e-mails.
Regards,
Bill I solved the problem by making the changes in registry with a VBScript.
Made a .exe of the script that runs automaticly as an Domain User With Admin Rights.
It makes changes in HKU insted of HKCU.- Marked As Answer bytp_tp Friday, September 04, 2009 9:14 PM
- Hello
I think i got a similar problem, could you give more detail on how you resolve the problem
I'm not a programmer and i got confuse.
I'm trying to start an apllcation from a shell command line in Excel. Work well with application that as not the "start as administrator" option
Martin

