Link to home
Start Free TrialLog in
Avatar of Manfredtoo
ManfredtooFlag for Singapore

asked on

Using powercfg with vbscript

Hi Experts
i have a piece of code here need some help, i couldnt get it run smoothly. my objective is to set the power management option with vbs. is there anything wrong with my sytax?

cheers
Dim objShell:Set objShell=CreateObject("Wscript.Shell")
On Error Resume Next
 
With objShell
 
  .Run "cmd powercfg /setactive "Home/Office Desk""
  .Run "cmd powercfg /x "Home/Office Desk" /monitor-timeout-ac 0"
  .Run "cmd powercfg /x "Home/Office Desk" /monitor-timeout-dc 0"
  .Run "cmd powercfg /x "Home/Office Desk" /disk-timeout-ac 0"
  .Run "cmd powercfg /x "Home/Office Desk" /disk-timeout-dc 0"
  .Run "cmd powercfg /x "Home/Office Desk" /standby-timeout-ac 0"
  .Run "cmd powercfg /x "Home/Office Desk" /standby-timeout-dc 0"
  .Run "cmd powercfg /x "Home/Office Desk" /hibernate-timeout-ac 0"
  .Run "cmd powercfg /x "Home/Office Desk" /hibernate-timeout-dc 0"
 
End With
 
wscript.quit

Open in new window

SOLUTION
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Manfredtoo

ASKER

thanks steve got it =)
steve: i tried again, it shows me error: expected end of statement.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
chandru: it works great =) thanks alot. hey been seeing u helping me quite a few times. really appreciate it
Glad i was of help! No worries

cheers
Chandru
powercfg with vbs