1.

Solve : How to Mass-close programs and Killing Processes?

Answer»

How would I go about writing a line of code to mass close all programs open


also to kill processes, induvidually.

And is there something to make the CD drive open on it's own accord?Why do you want this information?Well I'm using all this for a project I'm working on at school (not schoolwork just my own personal project)built off the logonexec that every STUDENT has to edit as they wish, it opens certain programs, logs off, opens the school's webmail, etc (thats what my other topic was asking about)

And now I want to implement the option of mass-closing programs so if the people I plan to give the batch file to want to get out of everything quickly for whatever reason they can just do that.

And the CD one for the lazy people who couldn't be screwed to lean over and press the button.

The kill process one I don't plan on putting in it.. just for my own curiosity and for me to play around with encase I need in future. Bump..im too lazy for killing all apps... just hit the side with your open hand. that should do the trick. What OS are you running? Do some research on TASKLIST (if you are running XP PRO) and TASKKILL.The school uses Windows 2000 and XPAnd Gary, I just read one of your other posts, for someone who likes to help you are SURE are QUICK to condemn people of using batch code for ill-mannered things.

I'm not interested in fixing something at work or getting my homework DONE

Nor am I trying to destroy/mess with every Tom, Di‬ck and Harry with my batch files.

Ever since I saw a profile cleaner made by some students from grade 12 last year I've been intrigued by batch code and it's possibilities

Now that I've started to learn how to make things work with batch files I want to learn more.

I assure you that I'm not using anything I learn off here for malicious purposes, but it's up to you, and whoever else wants to help to take my word for it.

I'll leave it at that. Have you done any code at all? I'll give you a tiny bit, and you can work off that.

Code: [Select]cd "C:\Docume~1\%username%\My Documents"
tasklist > tasklist.txt

REM In place of ^^^^ insert the programs you want to close (i.e. iexplore.exe,
REM winword.exe). Make a list of the programs that you use normally.
findstr ^^^^ tasklist.txt

Well, that's as far as I've got. Right now, all it does it echo the program if it is open. Try working from there.If you are planning on cycling thru the tasklist output, why not just use the shutdown command?

If you are referring to programs with open windows, you'll need programming access to the Windows API, which rules out batch code or scripts. I couldn't find a command or a class that references the open windows collection.

I'm guessing that "the CD one for the lazy people who couldn't be screwed to lean over and press the button" would also be too lazy to do a simple search as this has been posted many times before:

Code: [Select]Set WMP = CreateObject("WMPlayer.ocx")
Set colCDROMS = WMP.CDROMCollection

If colCDROMS.Count > -1 Then
For i = 0 to colCDROMS.Count - 1
colCDROMS.Item(i).Eject
Next
End If

Save the script with a vbs extension and run from the command prompt as cscript scriptname.vbs

You can also use Eject CD to eject the CD.




Quote from: Millenion on May 31, 2007, 01:07:01 AM

And Gary, I just read one of your other posts, for someone who likes to help you are sure are quick to condemn people of using batch code for ill-mannered things.

Sorry, but I've been taken advantage of before and I like to help people for positive reasons, but not negative. So I feel it is my responsibility to do what I can to reduce the possibility of my code being used for the dark side.

Under XP Pro, you can list the tasks with the TASKLIST command. You can either use the TASKLIST /FI to look for certain tasks or you can search for your items with a FOR /F loop. Then when you find the ones you want to kill use TASKKILL. Something like
Code: [Select]for /f "delims=1" %%a in ('tasklist') do (
if /i {%%a}=={notepad.exe} taskkill %%a
if /i {%%a}=={whatever.exe} taskkill %%a
)


Discussion

No Comment Found