Sillysack_Buttowski

I need help fast with this simpleton terminating script

12 posts in this topic

This is the script I created for terminating every process that starts at the start up. I got really fed up with doing this in the task manager, so, I decided to make a script. It works like it's supposed to but there's a teensy bit of a problem: it does not terminate "iexplore.exe". This said process starts up a little later than all the other programs and therefore, I had to change the script for it a bit. I added a processexists clause so that it knows that the process exists and then the processclose command. And the result? It DOES NOT WORK. Sorry for the caps.

; The following code terminates the given processes.
ProcessClose("Skype.exe")
ProcessClose("IDMan.exe")
ProcessClose("uTorrent.exe")
ProcessClose("DTShellHlp.exe")
ProcessClose("ONENOTEM.exe")
ProcessClose("DTAgent.exe")

; Wait indefinitely until Internet explorer launches; kill the process when it does.
If ProcessExists("iexplore.exe") Then ; Close the process.
   ProcessClose("iexplore.exe")
EndIf ; damn it, these stupid lines 10-12 won't work!

;The following code executes Google Chrome.
Run ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")

Terminator.au3

Share this post


Link to post
Share on other sites



Quote

; Wait indefinitely until Internet explorer launches; kill the process when it does.

If ProcessExists("iexplore.exe") Then ; Close the process.
   ProcessClose("iexplore.exe")
EndIf ; damn it, these stupid lines 10-12 won't work!

This does not wait indefinitely for that you need a loop: For(), While() or so.
Example:
 

While Not ProcessExists("iexplore.exe")
    Sleep(500)
WEnd
If ProcessExists("iexplore.exe") Then
   ProcessClose("iexplore.exe")
EndIf

; Or just simply like this:
While Not ProcessExists("iexplore.exe")
    Sleep(500)
WEnd
   ProcessClose("iexplore.exe")


Advise: Do not post with Title like: Urgent, FAST or so, people here help on their free time as volunteers so do not push them.

Regards
Alien.

Share this post


Link to post
Share on other sites

Why not just run MSCONFIG and shut them off once?


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 Gude
How 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

Share this post


Link to post
Share on other sites
1 hour ago, BrewManNH said:

Why not just run MSCONFIG and shut them off once?

That was on my mind too, but then I think maybe because the user who run this does not have Admins Rights... is the only answer that cross my mind.

Regards
Alien.

Share this post


Link to post
Share on other sites

@alien4u already provided a great solution to this issue. Just wanted to throw my 2 cents in so to say.

while 1
    if ProcessExists("iexplore.exe") > 0 then 
        ProcessClose("iexplore.exe")
        ExitLoop
    EndIf
    sleep(100);prevents excessive work on the cpu.
WEnd
MsgBox(0,"Notice","Loop escaped because iexplorer.exe was terminated.")

 


False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites

Thanks for all your help! Okay, I am sorry for posting "Fast" in the title and making people think that I was coercing them to help. Anyway, I'll now try out the new script. Other than that, I have another question that I can't find the answer to. It is not related to this post; should I make a new thread? Well I'll tell you anyway, it goes like this: I want to make a script that can automatically reconnect or should I say refresh my local internet connection to my mobile phone. See, I connect my phone via USB to my PC and share my PC's internet to my phone. Now every single I connect it I have to go into the control panel and disconnect and then reconnect it. I want this done via a script. Could you help me?

Share this post


Link to post
Share on other sites

If you do not want the program to stop forever just to try to kill a few programs use the following functions:

ConsoleWrite("!Close: " & _ProcessClose("Skype.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("IDMan.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("uTorrent.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("DTShellHlp.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("ONENOTEM.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("DTAgent.exe", 1) & " - Error:" & @error & @CRLF)

Func _ProcessClose($sProcess, $All = 0)
    Local $sPID = ProcessExists($sProcess)
    If Not $sPID Then Return SetError(0, 1, 0)
    Dim $Q = 0
    If $All Then
        While ProcessExists($sProcess)
            ProcessClose($sProcess)
            Sleep(1)
            $Q += 1
            If $Q > 10 Then ExitLoop
        WEnd
        If ProcessExists($sProcess) Then RunWait(@ComSpec & " /c taskkill /T /F /IM " & $sProcess, @SystemDir, @SW_HIDE)
    Else
        While ProcessExists($sPID)
            ProcessClose($sPID)
            Sleep(1)
            $Q += 1
            If $Q > 10 Then ExitLoop
        WEnd
        If ProcessExists($sPID) Then RunWait(@ComSpec & " /c taskkill /T /F /PID " & $sPID, @SystemDir, @SW_HIDE)
    EndIf
    Return SetError(0, 0, ProcessExists($sPID) = 0)
EndFunc   ;==>_ProcessClose


With each issue you to create a new thread!


With your 2nd question, I have a few suggestions.
To do that you need to install drivers "dial".
The sequel's script you will have to do is check that your device is connected to a computer or not.
If you're connected, it automatically make "dial".
That is all.


Regards,
 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

3 hours ago, Sillysack_Buttowski said:

Thanks for all your help! Okay, I am sorry for posting "Fast" in the title and making people think that I was coercing them to help. Anyway, I'll now try out the new script. Other than that, I have another question that I can't find the answer to. It is not related to this post; should I make a new thread? Well I'll tell you anyway, it goes like this: I want to make a script that can automatically reconnect or should I say refresh my local internet connection to my mobile phone. See, I connect my phone via USB to my PC and share my PC's internet to my phone. Now every single I connect it I have to go into the control panel and disconnect and then reconnect it. I want this done via a script. Could you help me?

Mention me when you make the new thread and I'll help.

Edited by BetaLeaf

False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites

Okay, I'll keep that in mind. Thanks, I think I'll make a new thread now.

Share this post


Link to post
Share on other sites
5 hours ago, BetaLeaf said:

Mention me when you make the new thread and I'll help.

Okay, I'll keep that in mind. Thanks, I think I'll make a new thread now.

 

8 hours ago, VIP said:

If you do not want the program to stop forever just to try to kill a few programs use the following functions:

ConsoleWrite("!Close: " & _ProcessClose("Skype.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("IDMan.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("uTorrent.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("DTShellHlp.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("ONENOTEM.exe", 1) & " - Error:" & @error & @CRLF)
ConsoleWrite("!Close: " & _ProcessClose("DTAgent.exe", 1) & " - Error:" & @error & @CRLF)

Func _ProcessClose($sProcess, $All = 0)
    Local $sPID = ProcessExists($sProcess)
    If Not $sPID Then Return SetError(0, 1, 0)
    Dim $Q = 0
    If $All Then
        While ProcessExists($sProcess)
            ProcessClose($sProcess)
            Sleep(1)
            $Q += 1
            If $Q > 10 Then ExitLoop
        WEnd
        If ProcessExists($sProcess) Then RunWait(@ComSpec & " /c taskkill /T /F /IM " & $sProcess, @SystemDir, @SW_HIDE)
    Else
        While ProcessExists($sPID)
            ProcessClose($sPID)
            Sleep(1)
            $Q += 1
            If $Q > 10 Then ExitLoop
        WEnd
        If ProcessExists($sPID) Then RunWait(@ComSpec & " /c taskkill /T /F /PID " & $sPID, @SystemDir, @SW_HIDE)
    EndIf
    Return SetError(0, 0, ProcessExists($sPID) = 0)
EndFunc   ;==>_ProcessClose


With each issue you to create a new thread!


With your 2nd question, I have a few suggestions.
To do that you need to install drivers "dial".
The sequel's script you will have to do is check that your device is connected to a computer or not.
If you're connected, it automatically make "dial".
That is all.

 

Okay, I'll start the new thread, though I do not understand what you mean by "dial". Well, that's a question for another day; maybe even literally.

Share this post


Link to post
Share on other sites
21 minutes ago, Sillysack_Buttowski said:

Okay, I'll keep that in mind. Thanks, I think I'll make a new thread now.

 

Okay, I'll start the new thread, though I do not understand what you mean by "dial". Well, that's a question for another day; maybe even literally.

What your phone name ? EG: Nokia Limua 620, Samsung S2, Iphone 4S,...

EG: Samsung A7
1. Download Samsung USB Driver (Install Samsung Kies or search on google)

2. Turn on: USB Internet OR Personal Hotpsot => Select "USB Cable"  OR Tethering & Portable hotspot => USB tethering
3. Connect Phone to Windows PC

4. Enter Network Connect and "dial" on Your Phone Name!


Regards,
 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

21 hours ago, BetaLeaf said:

@alien4u already provided a great solution to this issue. Just wanted to throw my 2 cents in so to say.

while 1
    if ProcessExists("iexplore.exe") > 0 then 
        ProcessClose("iexplore.exe")
        ExitLoop
    EndIf
    sleep(100);prevents excessive work on the cpu.
WEnd
MsgBox(0,"Notice","Loop escaped because iexplorer.exe was terminated.")

 

I don't see your great solution on this thread this is why I answer.
And I don't want to argue but your solution is the same as mine, but with 7 lines of code against 4 lines of code in the second version of my solution in post #2.
One more thing: I read here and learn here on this forum that Sleep(100) some times and in some specific Loops does not reduce CPU load in the way it should, and some old coders and autoit users recommend between Sleep(200) and Sleep(500), this is why I use Sleep(500) on the example because that will reduce CPU load for SURE.

Anyways thanks you for help.

Regards
Alien.

Edited by alien4u

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