Chaym Posted March 13, 2019 Share Posted March 13, 2019 Hi, I'm trying to get IO infos from an active service that is recognized with its PID. On Windows XP I get the IO infos, But on Window 7 And Windows 10 I get a failure with @error=1 What is wrong ? Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 13, 2019 Share Posted March 13, 2019 @Chaym Post your code, maybe? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Chaym Posted March 13, 2019 Author Share Posted March 13, 2019 (edited) It's basic: $SrvMemArray = ProcessGetStats($SRVPID, 0) If Not $SrvMemArray Then WriteToLog($LogFileHandle, $SrvName & " Error, PID " & $SRVPID & " Not Found - Macro terminated", $Append) EndIf On Windows Xp $SrvMemArray is not empty, the code passes the if statement On Windows7/10 it fails with @error = 1 Thank you BTW: I run this code as administartor Edited March 13, 2019 by Chaym Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 13, 2019 Share Posted March 13, 2019 @Chaym You could check the existence of the process Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Chaym Posted March 13, 2019 Author Share Posted March 13, 2019 (edited) The existence of the process is checked with $SRVPID = ProcessExists($SrvName) I get the Service PID Number ($SRVPID) then I use it in: $SrvMemArray = ProcessGetStats($SRVPID, 0) Edited March 13, 2019 by Chaym Link to comment Share on other sites More sharing options...
Nine Posted March 13, 2019 Share Posted March 13, 2019 (edited) Do you see the pid in task manager ? What version of autoit are you running ? What is the value of $SrvName ? You should have posted a runable script so we don't have to guess what could be the error... Edited March 13, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
BrewManNH Posted March 13, 2019 Share Posted March 13, 2019 ProcessGetStats returns an array, this code won't work. If Not $SrvMemArray Then You can't do a boolean check like that on an array. It's always going to bypass that check and go right into the If statement. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chaym Posted March 14, 2019 Author Share Posted March 14, 2019 (edited) Of course I see the Service And it's PID on task manager. It's an internal private service I use at work. "The existence of the process is checked with $SRVPID = ProcessExists($SrvName) " I do an boolean check on @error flag. ProcessGetStats() function sets non zero value on Failure (Array is empty) Auto version in 3.3.14.2 Thank you... Edited March 14, 2019 by Chaym Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 14, 2019 Share Posted March 14, 2019 (edited) 9 minutes ago, Chaym said: I do an boolean check on @error flag. You are using $SrvMemArray, which, in case of success, will be an array, which you can't do a boolean comparsion as @BrewManNH said, and, in case of failure, the @error code is set to a non-zero value. Better check the success/failure as mentioned in the example about ProcessGetStats(): Global $SrvMemArray = ProcessGetStats($SRVPID) If IsArray($SrvMemArray) Then ; Do something Else ; Error EndIf Edited March 14, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Chaym Posted March 14, 2019 Author Share Posted March 14, 2019 OK!, I'll try that... Link to comment Share on other sites More sharing options...
Chaym Posted March 14, 2019 Author Share Posted March 14, 2019 (edited) Well, using If IsArray I get an error, the array is empty... Any ideas? Edited March 14, 2019 by Chaym Link to comment Share on other sites More sharing options...
Developers Jos Posted March 14, 2019 Developers Share Posted March 14, 2019 (edited) The checked process is running at the same level, not admin? Post some code that is runnable and actually shows what you are doing so we can check for issues. Jos Edited March 14, 2019 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Chaym Posted March 17, 2019 Author Share Posted March 17, 2019 (edited) Here is the code (very simple) Local $ProcessName = "sqlservr.exe" Local $SQLPID = ProcessExists($ProcessName) WriteToLog($LogFileHandle, $ProcessName & ": $SQLPID = "&$SQLPID, $Append) Local $SqlMemArray = ProcessGetStats($SQLPID, 0) ;Memory Info's Local $ProcessStatusErr = @error WriteToLog($LogFileHandle, $ProcessName&" PID: "&$SQLPID&" / @error: "&$ProcessStatusErr, $Append) If Not IsArray($SqlMemArray) Then WriteToLog($LogFileHandle, $ProcessName&" Error: "&$ProcessStatusErr&" - PID: "&$SQLPID&" Not Found - Program terminated", $Append) ShowMess($HebStop, $ProcessName&" Error", $ProcessName&" Not found", -1) Else EndIf In WindowsXP OS it passes the If Not IsArray($SqlMemArray) In Widows 7 And Windows 10 it not passes, I Get @error=1 Thank you Chaim Edited March 17, 2019 by Chaym Link to comment Share on other sites More sharing options...
Developers Jos Posted March 17, 2019 Developers Share Posted March 17, 2019 7 minutes ago, Chaym said: Here is the code (very simple) Ok, but what about the answer to my first question? Under which credentials is the sqlservr.exe running? Have you tried your script with #RequireAdmin at the top of the script? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Chaym Posted March 17, 2019 Author Share Posted March 17, 2019 (edited) I tried now (again) with #RequireAdmin , it won't work. What do you mean "Under which credentials "? Can you explain please, from where can I see the credentials? I added print screen of task manger, in case it helps... I checked some processes. It seems that process where the user name in task manager is the login user name to windows (pos) are recognized. and the rest user names like SYSTEM and else are failing. What cad I do about that ? Edited March 17, 2019 by Chaym Link to comment Share on other sites More sharing options...
Developers Jos Posted March 17, 2019 Developers Share Posted March 17, 2019 1 minute ago, Chaym said: Can you explain please, from where can I see the credentials? The Username column! 2 minutes ago, Chaym said: It seems that process where the user name is login user name to windows (pos) are recognized. That makes sense as Win10 is much safer and processes can't just be access anymore like the good old win95/winXP days. So you do get the appropriate PID but can't get the process information... not even when elevated to Admin.... right? In that case you really need to check the security settings for the current account and the accounts used to run the services. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Chaym Posted March 18, 2019 Author Share Posted March 18, 2019 (edited) Yes, I get the PID but no information. I need to check the amount of memory the process uses (not the one in this example), IO info, etc... to see if there are memory or resource leaks. What should I do to get access to this services? Thank you... Edited March 18, 2019 by Chaym Link to comment Share on other sites More sharing options...
Developers Jos Posted March 18, 2019 Developers Share Posted March 18, 2019 16 hours ago, Jos said: In that case you really need to check the security settings for the current account and the accounts used to run the services. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Chaym Posted March 18, 2019 Author Share Posted March 18, 2019 (edited) Well, I changed in Log On tab to the check box to This account and entered the login account. It works for windows 7, But not work for windows 10. Any idea? Thank you. Edited March 18, 2019 by Chaym Link to comment Share on other sites More sharing options...
Chaym Posted March 18, 2019 Author Share Posted March 18, 2019 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