Sign in to follow this  
Followers 0
Andrew Peacock

Compiled Script on Startup Problems

3 posts in this topic

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

post-8991-1230542669_thumb.gif

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 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

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