Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Box Problem

Status
Not open for further replies.

Sasstraliss

Programmer
Apr 7, 2009
21
AU
Alright, so this is how my script works.

You open it, and you get an input box which you type the name of a remote computer into.
Then, after you hit enter, you get another input box asking you the name of the process you want to end remotely.

This is my problem; the first input box seems to work fine, but the second one asking for a process name does not work.

It gives me an error. Please, try it out yourself and see, any help on this would be greatly appreciated.

Code:
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill

strComputer = (InputBox(" ", "Internet Explorer (Not Responding)"))
If strComputer <> "" And strComputer <> "q" And strComputer <> "w" And strComputer <> "e" And strComputer <> "r" And strComputer <> "t" And strComputer <> "y" And strComputer <> "u" And strComputer <> "i" And strComputer <> "o" And strComputer <> "p" And strComputer <> "a" And strComputer <> "s" And strComputer <> "d" And strComputer <> "f" And strComputer <> "g" And strComputer <> "h" And strComputer <> "j" And strComputer <> "k" And strComputer <> "l" And strComputer <> "z" And strComputer <> "x" And strComputer <> "c" And strComputer <> "v" And strComputer <> "b" And strComputer <> "n" And strComputer <> "m" Then

strProcessKill = (InputBox(" ", "Internet Explorer (Not Responding)"))
If strComputer <> "" And strComputer <> "q" And strComputer <> "w" And strComputer <> "e" And strComputer <> "r" And strComputer <> "t" And strComputer <> "y" And strComputer <> "u" And strComputer <> "i" And strComputer <> "o" And strComputer <> "p" And strComputer <> "a" And strComputer <> "s" And strComputer <> "d" And strComputer <> "f" And strComputer <> "g" And strComputer <> "h" And strComputer <> "j" And strComputer <> "k" And strComputer <> "l" And strComputer <> "z" And strComputer <> "x" And strComputer <> "c" And strComputer <> "v" And strComputer <> "b" And strComputer <> "n" And strComputer <> "m" Then

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next

End if
End if

WScript.Quit
 
Hi there.
Is it a problem with the inputbox or with the code preceding it? Does the input box show at all?
What is the error message you are receiving?

Dave.
 
Try the code yourself and see ;)
I get the error after the second inputbox.

It says Line 17 Line 1.
 
OK. The problem is with the query you are using. Strings need to have surrounding quotes.
Code:
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = [COLOR=red]'[/color]" & strProcessKill & [COLOR=red]"'"[/color])
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top