nf67 Posted September 16, 2010 Share Posted September 16, 2010 (edited) Hi there, this is a quick script I've created to demonstrate the problem, is there anyone that could get this to work? #include <Process.au3> $Processes = ProcessList() For $Process = 1 to $Processes[0][0] $Memory = ProcessGetStats($Processes[$Process][1]) ;Fails, returns 0. Therefore, it isn't an array and the script crashes later on. FileWriteLine(@ScriptDir & "Processes.txt","--Name:" & $Processes[$Process][0] & _ " --Priority:"& _ProcessGetPriority($Processes[$Process][1]) & _ " --Work Memory:"& $Memory[0] & _ " --Peak Memory:"& $Memory[1]) Next ShellExecute(@ScriptDir & "Processes.txt") Thanks a bunch, Edited September 16, 2010 by nf67 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 16, 2010 Share Posted September 16, 2010 You forgot the slash after @scriptdir ShellExecute(@ScriptDir & "\Processes.txt") And to stop the crash check the return value: Return Value Success: An array of infos data (See Remarks). Failure: 0. Example: #include <Process.au3> $Processes = ProcessList() For $Process = 1 to $Processes[0][0] $Memory = ProcessGetStats($Processes[$Process][1]) ;Fails, returns 0. Therefore, it isn't an array and the script crashes later on. If $Memory = 0 Then ContinueLoop FileWriteLine(@ScriptDir & "\Processes.txt","--Name:" & $Processes[$Process][0] & _ " --Priority:"& _ProcessGetPriority($Processes[$Process][1]) & _ " --Work Memory:"& $Memory[0] & _ " --Peak Memory:"& $Memory[1]) Next ShellExecute(@ScriptDir & "\Processes.txt") Or: #include <Process.au3> $Processes = ProcessList() For $Process = 1 to $Processes[0][0] $Memory = ProcessGetStats($Processes[$Process][1]) ;Fails, returns 0. Therefore, it isn't an array and the script crashes later on. FileWriteLine(@ScriptDir & "\Processes.txt","--Name:" & $Processes[$Process][0] & _ " --Priority:"& _ProcessGetPriority($Processes[$Process][1])) If $Memory <> 0 Then FileWriteLine(@ScriptDir & "\Processes.txt", " --Work Memory:"& $Memory[0] & _ " --Peak Memory:"& $Memory[1]) EndIf Next ShellExecute(@ScriptDir & "\Processes.txt") .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
nf67 Posted September 16, 2010 Author Share Posted September 16, 2010 Yes I had already implemented such a check, but that's not really my main problem, sorry. If the list of processes is retrieved by ProcessList() just a milisecond before ProcessGetStats() runs, why would it ever fail? Sorry for the slashes! Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 16, 2010 Share Posted September 16, 2010 I don't know, but by looking at Processes.txt from the second script in my post I would say it's services and stuff that you aren't supposed to touch. Also doing ProcessGetStats on an app with higher privileges seems to fail. Run as admin to get as much information as possible= #RequireAdmin ;for au3-files #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator ;for exe-files .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
nf67 Posted September 18, 2010 Author Share Posted September 18, 2010 Thanks for your info, Alkex, I'll include that. Link to comment Share on other sites More sharing options...
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