Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey, I am completely new to batch files and things like that. What I have is a program that runs batch files that open up other programs. So far all good. But since this is a loop and it keeps opening windows I would somehow be able to close the old ones or all of the same type, is it possible to have another batch file do this?
For example:
batch1.bat runs text1.txt
batch2.bat runs text2.txt
batch3.bat runs text3.txt
batch4.bat closes all opened .txt-filesJust an example, I guess other ways may be better to do this.
I've tried looking for exit commands but since I'm completely new to this it's also hard to know how to look for it =)
Thanks in advance

You mean the cmd.exe window? When I test that it doesn't work. It does work writing "start text1.txt" though so I have no problem with the cmd.exe window.
The thing is that I get several .txt windows.
text1.txt, text2.txt and since it's a loop I get several text1.txt and text2.txt that floods the icon tray for eternity.
I search some command, or function (if there are any good way not using batch files) so that all these old txt-windows close and I only have the fresh one of the same kind.
(It is really hard for me to exlain these things with good computer-vocaublary so I hope you understand what I'm searching for =))

The original batch file should first run a "program" to pickup the text file. For example:
"c:\windows\notepad.exe" "text1.txt"
exit(the quotes are only essential if there are spaces in the path or the number of characters in any file or folder is greater than 8).
When the above has run the program will stop and the window will close.
exit is on the next line in this simple example, which does not need an additional batch file to close it. It also assumes the batch file is in the same folder as the text file.
DerekW

Nope, still doesn't work for me =/
I have main1.bat and info.txt in same folder.
This is in the .bat file:
start c:\winxp\notepad.exe info.txtThis opens the text-file when I run it. If I run it again it opens a new text-file window. So it's no difference, I still get several windows. And I don't get the exit command to work (but with the start I don't need it since the cmd.exe window closes automaticly).
This seem to work for you guys but not for me. Can it have something to do with OS system or something that is way above my knowledge?

Well, I guess I was too hasty. It's just that it is normal to call the program first, so that was a good thing to do anyhow. You can rest assured that it is not something you are doing wrong in princple or anything to do with the OS.
I do now see your problem (tried it) but am short of ideas on how to deal with it because there is no easy means to identify some text file that is open without invoking a fancy third party program. It is a somewhat unusual thing to be wanting to do....
Maybe if you go right back to exactly what you want to achieve (assuming it is not just opening and closing text files) then perhaps I can see some other way of approaching the task using batch files.
DerekW

There is a program called Ghostmouse with the extension .gsm which is a program that let's you record your mouse movements and clicks. I'm very bad at scripting in general but with flash I can control running these .gsm files in a way that suits what I need this for. Batch files have to be used since flash can't call .exe files.
The GMouse-files do the thing they do and then they stop. After that a new .gsm-file is called to run.
My problem is that if I leave this running for a little time I'll have 100 windows of GMouse open flooding the computer and that is what I try to avoid.
Gmouse can for some reason not close itself by it's own clickings. And I used .txt-files as an exmple not to involve weird programs that people doesn't know about to make it easier to help me :)
And thanks a lot for the time you put into answering this thread, I really appreciate it =)

Yes, I recall Gmouse. Well, just off the top of my head I guess you could write a batch file to delete all .gsm files once they have run. Not sure if it will let you (as they are still in use) but its worth a try.
I have to say that closing programs with batch files is always a stumbling block so you have started off in a difficult area.If the .gsm files are in the same folder as the batch file it just needs to say
del /q *.gsm
The /q is the quiet "switch" (used in XP DOS emulator) so that you don't have to say Yes to each deletion.
If the batch file is located elsewhere then you need to specifiy the full path to the .gsm's, like this:
del /q "c:\foldername\*.gsm"
No need for quotes if folder name is less than 8 characters including spaces. Note that in DOS the backslash is normally used for paths and so on. Switches (which qualify the command) use the forward slash.
I might not have properly understood your situation because it's ages since I looked into Gmouse. Maybe it will give you some ideas if nothing else.
On a personal note have you an interest in trams
(I spotted "tramtram")? I'm from the UK and Tram is the word we use instead of Trolleycars - USA.DerekW

No, I don't want to delete the files, just close them :)
But I've managed to find a way now. I downloaded pskill and with the help of that I can now "kill" all the .gms-windows (not .gsm as I wrote) that are open with a .bat file very effectively. It seems like this is some kind of hacker program too with security risks so I don't know if it's good to have on the computer :P
But I changed the name of the file from pskill.exe to like... killkillkill.exe so hopefully hackers won't be able to use it if they somehow get on my comp (I'm an ignorant when it comes to this stuff) but it still works just as good.
My name Tramtram was just something I took from the top of my head. I'm very bad with finding out nick names for accounts and I didn't even know what a tram was (I've heard it before but wouldn't know if someone asked me what it was). Just made something up that sounded fun :P

Glad to hear you sorted it. That PSKill looks good, I've downloaded it.
As for the security risk, as far as I can make out it is safe enough in its own right (not a virus/trojan/malware or anything like that). It's just that in the wrong hands it can be made to do a few dirty deeds on folks machines.
Oh well, now you know what your monica means (well in the UK anyhow). Shortened version of our word "tramcar", usually refers to ancient vehicles. Streetcar is another USA variant.
DerekW

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |