Andrew Peacock Posted December 29, 2008 Posted December 29, 2008 Hi, I've got a script compiled into an EXE that runs fine when I'm logged in and start it manually. But when I launch it on startup (user login, not system startup), I get the following error (as shown in attached file) The relevant section of code is: CODE$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems if StringInStr($objItem.CommandLine, $pagename, False) then ;consolewrite(@crlf & "$pagename$: Got process " & $objItem.caption & ":" & $objItem.CommandLine) $commandLine = $objItem.Commandline if StringInStr($commandLine, $pagename) Then ;_DebugOut ("True") ; Get process details $aProcesses = _ProcessListProperties($objItem.ProcessId) ConsoleWrite(@crlf & "CPU: " & $aProcesses[1][6]) ; <<<<<< LINE 305 <<<<<<<<<<< return $objItem.ProcessId EndIf ;_DebugOut ("False") Else ; consolewrite(@crlf & "didn't find $pagename$ in " & $objItem.CommandLine) EndIf Next EndIf Any ideas why this works OK once I'm logged on and the PC has finished processing my logon (ie, I can work normally), but doesn't if it's fired at the point the PC is still going through the logon process? Or do you have any suggestions/warnings about adding a one-off delay that runs when the EXE first runs? Regards, Andy
FireFox Posted December 29, 2008 Posted December 29, 2008 (edited) @Andrew It seems that the system hasnt completly started, try to run your script with regedit at startup on the RunOnceEx for it start after system finish loading Cheers, FireFox. Edited December 29, 2008 by FireFox
PsaltyDS Posted December 29, 2008 Posted December 29, 2008 (edited) Get some more debug info like this: If StringInStr($commandLine, $pagename) Then ; Get process details ConsoleWrite("Debug: $objItem.ProcessId = " & $objItem.ProcessId & @LF) $aProcesses = _ProcessListProperties($objItem.ProcessId) _ArrayDisplay($aProcesses, "Debug: $aProcesses") ConsoleWrite(@CRLF & "CPU: " & $aProcesses[1][6]) Return $objItem.ProcessId EndIf This will tell you if you are passing a valid PID, and will show the array _ProcessListProperties() is returning. P.S. Change the ConsoleWrite() functions to _FileWriteLog() or MsgBox() if you don't see those debug outputs. Edited December 29, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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