Jump to content

Simple Taskkill Script *Solved*


 Share

Recommended Posts

I am trying to make a simple taskkill script and trying new ideas to get it to work but this is not working. Can it even be done like this? This is my first time attempting an InputBox.

Most currently I get: ERROR: The network path was not found.

#Include <Constants.au3>

$s_Machine = InputBox("Input", "Enter Computer Name")
$s_Process = InputBox("Input", "Process to Exterminate")

$run = Run("taskkill /s ($s_Machine) /u domain\username /p password /im ($s_Process)", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

;taskkill /s (computer) /u (domain)\(user) /p (pass) /im (app name) - what I use now and works fine at command prompt.

While 1
    $line = StdoutRead($run)
    If @error Then ExitLoop
    MsgBox(0, "Sucess:", $line)
Wend


While 1
    $line = StderrRead($run)
    If @error Then ExitLoop
    MsgBox(0, "Error:", $line)
WEnd

I am an admin and have full access/permissions to the domain; the problem I am having is when a particular accounting add-in for Excel frequently locks up, (which happens a lot) the user has to close out Excel, end the process then re-open Excel so the add-in can reload. Unfortunetly you know how starfish are, they do not know how to do this even after showing them 1000 times. I normally have to walk them through a Task Manager, End Process (if they are capable of following basic instructions) or I remote in and do it myself(usually what happens). Frankly, I would rather starfish not know about Task Manager / End Process.

Currently I use Taskkill and it works like a charm but I have others that I would like to be able to do this process for me and I was trying to think of a way to make the process somewhat "stupid free".

Edited by schilbiz
Link to comment
Share on other sites

This isn't PHP, you can't embed variables in a string without concatenation.

$runString = StringFormat("taskkill /s (%s) /u domain\username /p password /im (%s)", $s_Machine, $s_Process)
$run = Run($runString, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

P.S. - Wtf is this starfish nonsense? Is your name Nemo?

Link to comment
Share on other sites

This isn't PHP, you can't embed variables in a string without concatenation.

$runString = StringFormat("taskkill /s (%s) /u domain\username /p password /im (%s)", $s_Machine, $s_Process)
$run = Run($runString, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

P.S. - Wtf is this starfish nonsense? Is your name Nemo?

I still get the same error: ERROR: The network path was not found.

I had to think about the starfish comment, and I think I picked it up from reading too much Tech Support Comedy - http://www.techcomedy.com Spend 10 minutes on there and you will understand where starfish comes from.

Specifically: http://www.techcomedy.com/past_stories.php...December%202007

Link to comment
Share on other sites

I am still having the same problem with this, (ERROR: The network path was not found.) Is there a different/better way to embed a variable?

#Include <Constants.au3>

$s_Machine = InputBox("Input", "Enter Computer Name")
$s_Process = InputBox("Input", "Process to Exit")

$runString = StringFormat("taskkill /s (%s) /u domain\username /p password /im (%s)", $s_Machine, $s_Process)
$run = Run($runString, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

While 1
    $line = StdoutRead($run)
    If @error Then ExitLoop
    MsgBox(0, "Sucess:", $line)
Wend

While 1
    $line = StderrRead($run)
    If @error Then ExitLoop
    MsgBox(0, "Error:", $line)
WEnd
Link to comment
Share on other sites

You aren't even using the proper syntax for taskkill. You are surrounding variables with parentheses and that is incorrect.

Go to command prompt and type: taskkill /?

I got it working, I was basing the (%s) off of what you had mentioned taking you literal, but the below code works great, thanks for the help.

#Include <Constants.au3>

$s_Machine = InputBox("Input", "Enter Computer Name")
$s_Process = InputBox("Input", "Process to Exit")

$runString = StringFormat("taskkill /s %s /u username /p password /im %s", $s_Machine, $s_Process)
$run = Run($runString, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)


While 1
    $line = StdoutRead($run)
    If @error Then ExitLoop
    MsgBox(0, "Sucess:", $line)
Wend

While 1
    $line = StderrRead($run)
    If @error Then ExitLoop
    MsgBox(0, "Error:", $line)
WEnd
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...