DEVIOUZ Posted January 26, 2008 Share Posted January 26, 2008 is there any way to use this code "If Not ProcessExists "like this: If Not ProcessExists("c:\folder\smss.exe") Then Run("c:\folder\smss.exe") I need to check if a specific process is running from a specific location and if its not then it needs to be started. but the process is the same name as an already running process so it doesn't seem to work.. and I don't want to rename my process to something other than what it is (smss.exe) because that way no one can end my process via taskmanager. so is what im asking possible at all..?? Link to comment Share on other sites More sharing options...
MrCreatoR Posted January 26, 2008 Share Posted January 26, 2008 (edited) Hi,Check this UDF:expandcollapse popup$PathIsProcess = _ProcessPathExists("c:\folder\smss.exe") MsgBox(0, '', $PathIsProcess & @LF & @extended) ;=============================================================================== ; ; Function Name: _ProcessPathExists() ; Description: Check if given path is an existing process. ; ; Parameter(s): $sPath - Path of executable to check. ; ; Requirement(s): AutoIt v3.2.8.1 or higher. ; Kernel32.dll (included with Windows) ; Psapi.dll (included with most Windows versions) ; ; Return Value(s): On Success - Returns PID of executable process, @extended include total number of similar processes runing. ; On Failure - Returns False and sets @Error to: ; 1 - Given path not exists. ; 2 - Process with name of the executable not exists. ; 3 - Error to open Psapi.dll. ; 4 - Error to call Kernel32.dll. ; 5 - Unknown/other error related to DllCalls. ; ; Author(s): G.Sandler (a.k.a CreatoR) ; ;=============================================================================== Func _ProcessPathExists($sPath) If Not FileExists($sPath) Then Return SetError(1, 0, False) Local $sPathName = StringRegExpReplace($sPath, "^.*\\", "") Local $aProcList = ProcessList($sPathName) If Not ProcessExists($sPathName) Then Return SetError(2, 0, False) Local $iUbound = UBound($aProcList)-1 Local $hPsapi_Dll = DllOpen('Psapi.dll') If $hPsapi_Dll = -1 Then $hPsapi_Dll = DllOpen(@SystemDir & '\Psapi.dll') If $hPsapi_Dll = -1 Then $hPsapi_Dll = DllOpen(@WindowsDir & '\Psapi.dll') If $hPsapi_Dll = -1 Then Return SetError(3, 0, False) Local $aProc, $aPath Local $vStruct = DllStructCreate('int[1024]') For $i = 1 To $iUbound $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $aProcList[$i][1]) If Not IsArray($aProc) Or Not $aProc[0] Then Return SetError(4, 0, False) DllCall($hPsapi_Dll, 'int', 'EnumProcessModules', _ 'hwnd', $aProc[0], _ 'ptr', DllStructGetPtr($vStruct), _ 'int', DllStructGetSize($vStruct), _ 'int*', 0) $aPath = DllCall($hPsapi_Dll, 'int', 'GetModuleFileNameEx', _ 'hwnd', $aProc[0], _ 'int', DllStructGetData($vStruct, 1), _ 'str', '', _ 'int', 2048) If IsArray($aPath) And $aPath[3] = $sPath Then DllClose($hPsapi_Dll) Return SetExtended($iUbound, $aProcList[$i][1]) EndIf Next DllClose($hPsapi_Dll) Return SetError(5, 0, False) EndFuncEdit: changed int_ptr to int* (so it will work with latest AutoIt version). Edited January 26, 2008 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Siao Posted January 26, 2008 Share Posted January 26, 2008 Woot, now the guy can finish his l33t virus... "be smart, drink your wine" Link to comment Share on other sites More sharing options...
DEVIOUZ Posted January 26, 2008 Author Share Posted January 26, 2008 im not making a viruz.. why u saa that 4..?? Anyway thanks for the code MsCreatoR, but when i run it in scite editor it it gives me some message box that only says: False 0 the process c:\folder\smss.exe is not running when i run the script, and the c:\folder\smss.exe doesnt get executed..?? do i need to edit the code at all or what exactly..?? Sorry, I'm new to autoit so please bare with me.. Link to comment Share on other sites More sharing options...
BrettF Posted January 26, 2008 Share Posted January 26, 2008 Woot, now the guy can finish his l33t virus...Yer. I just noticed that too... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 im not making a viruz.. why u saa that 4..??-snip-Sorry, I'm new to autoit so please bare with me..So enlight us what is it you want to accomplish here ? 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...
DEVIOUZ Posted January 26, 2008 Author Share Posted January 26, 2008 So enlight us what is it you want to accomplish here ?i did in my first post... Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 not why you wanted to do this ... 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...
DEVIOUZ Posted January 26, 2008 Author Share Posted January 26, 2008 I thought these forums were for getting help & support for using Autoit, I'm just asking for a lil help here... why do I have to get accused of making a virus, then giving th 3rd degree about it. I just want to make a simple autoit app to check if a specific process is running from a specific location and if its not then it gets started. how is that a virus...?? Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 I thought these forums were for getting help & support for using Autoit,I'm just asking for a lil help here...why do I have to get accused of making a virus, then giving th 3rd degree about it.I just want to make a simple autoit app to check if a specific process is running from a specific location and if its not then it gets started.how is that a virus...??You know... its really simple. Add the way you asked the question and the "words" you use together with your membername and you get as result "suspicious".The way you answer the questions asked really only confirm the feelings.Now, don't get me wrong here, I am not accusing you of anything (yet)..Its your choise what you ask and how you reply, but I won't help you unless I get a better feeling for what you truly want here. 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...
DEVIOUZ Posted January 26, 2008 Author Share Posted January 26, 2008 nuff wif all teh damn hatin already.. sheesh discriminating on me mow jus cuz of my name wtf.. so should i change it then to "carebearwuss143" will that make you happy. LOL.. sorry if you take my posts the wrong way, but i just came here to get some help not to be interrogated. so in what way did i ask my question, that makes yall think im makin a viruz..?? look You know... its really simple, as i've asked before. I just want to make a simple autoit app to check if a specific process is running from a specific location and if its not then it gets started. sorry, but i don't see anything malicious about that do you.. you need a better feeling for what I truly want here..?? how many times do i have to say it..?? What I truly want is to make a simple autoit app to check if a specific process is running from a specific location and if its not then it gets started." Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 You seem to have a problem reading my posts. Also writing normal English so people like myself are able to understand you seems to be difficult for you. Anyways ... as said: do as you please ... 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...
DEVIOUZ Posted January 26, 2008 Author Share Posted January 26, 2008 look man i aint got no beef with you nore anyone else in here ok. can we just put all this BS aside and get back on topic here.. what do you need me to do to get some help..?? Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 (edited) As long as I don't understand the purpose of your question I won't be helping you. You could have made it sooo much easier by just telling us about what you really want to do in stead of getting in your high horse and starting the "wtf language bs". Now why on earth would you want to know if smss.exe is started from folder "x" and when it isn't start it from there as well ? Edited January 26, 2008 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...
DEVIOUZ Posted January 26, 2008 Author Share Posted January 26, 2008 I already told you what i wanted to do, cmon man im just defending myself from these virus accusations.. smss.exe is just a security app i use, and i don't want anyone else that uses my PC to be able to close it, so if they do, this auto it app will auto reopen it upon detecting it not running.. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 (edited) I already told you what i wanted to do, cmon manim just defending myself from these virus accusations..smss.exe is just a security app i use, and i don't want anyone else that uses my PC to be able to close it, so if they do, this auto it app will auto reopen it upon detecting it not running..Read the below article and just shut up being a whiner about being accused of something, maybe you realize why you sound (and keep on sounding) suspicious:http://www.neuber.com/taskmanager/process/smss.exe.html*I am done with you and this thread is as well.. click* Edited January 26, 2008 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...
Recommended Posts