1.

Solve : .bat file that prompts for info?

Answer»

Hello,

I have a user that loves to play games and watch movies during working hours (as we all do), I often use pskill.exe and pslist.exe from sysinternals (fun little apps that lists & kills processes remotely on client machines) to get the job done, but I am trying to automate it a bit more (getting lazy) by setting up two .bat files (one if possible) that will:

a.) Launch PSLIST in a DOS window with programs variables set while keeping the DOS window open.
b.) Launch PSKILL in a seperate DOS window with a PROMPT for the next command in the comand line.

What I have done thus far...which works for my purposes.
a.) I setup a shortcut with the target of: C:\WINDOWS\system32\cmd.exe /K C:\whodunnit.bat to keep the DOS window open. The 1st .bat (whodunnit.bat) file goes like this:

Code: [Select]c:
@ ECHO OFF
title OPERATION KILLJOY!
START "KILLJOY" c:\whodunnit2.bat /MAX
pslist -t \\COMPUTERNAME -u COMPUTERNAME\administrator -p LOCALPASSWORD
b.) This is where I'm stuck, is there a command that allows DOS to prompt you for the next command/INPUT, such as entering a computer NAME or typing in a non-static number (process thread) with the ability to press ENTER to initialize it??? I was even thinking of creating a MENU if that would seem feasible enough. What I have so far on c:\whodunnit2.bat:

Code: [Select]c:
@ ECHO OFF
pskill -t \\COMPUTERNAME -u COMPUTERNAME\administrator -p LOCALPASSWORD 1028
The 1028 in the command would be the non-static thread number that would change dynamically, it could also be replaced by the .exe name of the process. Any ideas out there? Or...I could try to setup TASKLIST & TASKKILL for the same results off a .bat file.In a perfect world the poster would tell us what OS is being used instead of us trying to guess with hints scatttered in the post.

Try using set /p var=prompt

prompt can be any literal string. You can then use %var% in your code.

8-)If I understand your goal, I think you are looking for something like:

Code: [Select]@ ECHO OFF
title OPERATION KILLJOY!
:PSList
pslist -t \\COMPUTERNAME -u COMPUTERNAME\administrator -p LOCALPASSWORD
echo.
set /p pid=Enter the PID to kill or [Enter] to quit:
if {%pid%}=={} GOTO :EOF
pskill -t \\COMPUTERNAME -u COMPUTERNAME\administrator -p LOCALPASSWORD %pid%
goto :PSListQuote

In a perfect world the poster would tell us what OS is being used instead of us trying to guess with hints scatttered in the post.

Try using set /p var=prompt

prompt can be any literal string. You can then use %var% in your code.

8-)

Please forgive my insolence, for as many people as I help on a day-to-day basis, not including the plethora of years working in I.T., it did not once even cross my mind to communicate the OS I was working with. Our client machines & my own are WinXP Pro-SP2, we like to keep things pretty standard here. Again, my apologies and thank you much for responding to my post.

Quote
If I understand your goal, I think you are looking for something like:

Code: [Select]@ ECHO OFF
title OPERATION KILLJOY!
:PSList
pslist -t \\COMPUTERNAME -u COMPUTERNAME\administrator -p LOCALPASSWORD
echo.
set /p pid=Enter the PID to kill or [Enter] to quit:
if {%pid%}=={} goto :EOF
pskill -t \\COMPUTERNAME -u COMPUTERNAME\administrator -p LOCALPASSWORD %pid%
goto :PSList

You sir...ARE A GENIUS! You ROCK!
That is my own way of saying thank you. It becomes very evident that I really need to learn more about the different functions of variables and use it more DAILY. Again, thank you...I have certainly come to the right place and I hope to be able to add my own instruction helping others likewise.

Cheers!


Discussion

No Comment Found