Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


PowerCFG Script issue

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,64635
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> PowerCFG Script issue
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 PowerCFG Script issue - 9/29/2008 1:22:46 AM   
  gcibirch

 

Posts: 9
Score: 0
Joined: 5/6/2008
Status: offline
Hi

Can anyone help with the following script:

Set oShell = CreateObject("Wscript.Shell")
Set oEnvironment=oShell.Environment("Process")
sComputerName=oEnvironment("COMPUTERNAME")
oShell.Run "powercfg.exe -devicequery wake_from_any", 0, True > c:\" &sComputerName & ".txt"
End If

I am trying to run this on the local computer and to write the results to a file, using the computername. When I run it I get "C:\device.vbs(4, 67) Microsoft VBScript compilation error: Expected statement".

Thanks
 
 
Post #: 1
 
 RE: PowerCFG Script issue - 9/29/2008 1:31:01 AM   
  dm_4ever


Posts: 2670
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
oShell.Run "powercfg.exe -devicequery wake_from_any", 0, True > c:\" &sComputerName & ".txt"

That line is just wrong....look at some examples and documentation and you should see why.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to gcibirch)
 
 
Post #: 2
 
 RE: PowerCFG Script issue - 9/29/2008 1:35:34 AM   
  gcibirch

 

Posts: 9
Score: 0
Joined: 5/6/2008
Status: offline
Cheers.

I know its wrong but just cannot find the answer.


(in reply to gcibirch)
 
 
Post #: 3
 
 RE: PowerCFG Script issue - 9/29/2008 1:39:07 AM   
  gcibirch

 

Posts: 9
Score: 0
Joined: 5/6/2008
Status: offline
Ok.

I have made some amendments and the script runs but doesn' create the file:

Set oShell = CreateObject("Wscript.Shell")
Set oEnvironment=oShell.Environment("Process")
sComputerName=oEnvironment("COMPUTERNAME")
oShell.Run ("powercfg.exe -devicequery wake_from_any, 0, True > c:\" &sComputerName & ".txt")

(in reply to gcibirch)
 
 
Post #: 4
 
 RE: PowerCFG Script issue - 9/29/2008 3:43:34 AM   
  gcibirch

 

Posts: 9
Score: 0
Joined: 5/6/2008
Status: offline
Hi,

I have found another script and done some amendments:

Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
WScript.Echo "Computer Name: " & strComputerName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set envProcess = objShell.Environment("process")
windir = envProcess.Item("windir")
rtnversion = wshShell.Run(windir & "\system32\powercfg.exe -devicequery wake_from_any", 0, true)
Set objTextFile = objFSO.CreateTextFile ("C:\" &strComputerName & ".txt")
WScript.Echo rtnVersion
objTextFile.WriteLine rtnVersion

however it returns with 0 and not a list of devices..any help would be appreciated.


(in reply to gcibirch)
 
 
Post #: 5
 
 RE: PowerCFG Script issue - 9/29/2008 4:01:15 AM   
  dm_4ever


Posts: 2670
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
actually your previous one is closer....try

oShell.Run "%comspec% /c powercfg.exe -devicequery wake_from_any > c:\" & sComputerName & ".txt", 0, True

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to gcibirch)
 
 
Post #: 6
 
 RE: PowerCFG Script issue - 9/29/2008 7:01:14 PM   
  gcibirch

 

Posts: 9
Score: 0
Joined: 5/6/2008
Status: offline
Thanks for this.

You are right Keep it simple

(in reply to dm_4ever)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> PowerCFG Script issue Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts