Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: .bat file that prompts for info  (Read 5989 times)

0 Members and 1 Guest are viewing this topic.

asciikerr

  • Guest
.bat file that prompts for info
« on: July 06, 2006, 12:13:31 PM »
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??? :P  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? ;D
« Last Edit: July 06, 2006, 12:53:28 PM by asciikerr »

asciikerr

  • Guest
Re: .bat file that prompts for info
« Reply #1 on: July 06, 2006, 01:25:01 PM »
Or...I could try to setup TASKLIST & TASKKILL for the same results off a .bat file.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: .bat file that prompts for info
« Reply #2 on: July 06, 2006, 03:11:32 PM »
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-)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

GuruGary



    Adviser
    Re: .bat file that prompts for info
    « Reply #3 on: July 07, 2006, 01:21:31 AM »
    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

    asciikerr

    • Guest
    Re: .bat file that prompts for info
    « Reply #4 on: July 07, 2006, 08:02:14 AM »
    Quote
    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!