Computing.Net > Forums > Windows XP > Close windows with batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Close windows with batch

Reply to Message Icon

Name: Tramtram
Date: May 28, 2007 at 08:32:46 Pacific
OS: Win XP
CPU/Ram: AMD 512
Product: HP
Comment:

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-files

Just 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




Sponsored Link
Ads by Google

Response Number 1
Name: Curt R
Date: May 28, 2007 at 09:29:50 Pacific
Reply:

If you use the command "exit" at the end of a batchfile, it will close the window.


0

Response Number 2
Name: Tramtram
Date: May 28, 2007 at 12:03:23 Pacific
Reply:

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 =))


0

Response Number 3
Name: Derek
Date: May 28, 2007 at 18:51:38 Pacific
Reply:

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


0

Response Number 4
Name: Tramtram
Date: May 29, 2007 at 05:35:31 Pacific
Reply:

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.txt

This 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?


0

Response Number 5
Name: Derek
Date: May 29, 2007 at 12:11:20 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: Tramtram
Date: May 31, 2007 at 04:13:45 Pacific
Reply:

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 =)


0

Response Number 7
Name: Derek
Date: May 31, 2007 at 10:11:12 Pacific
Reply:

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


0

Response Number 8
Name: Tramtram
Date: May 31, 2007 at 14:45:22 Pacific
Reply:

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


0

Response Number 9
Name: Derek
Date: May 31, 2007 at 15:46:01 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Close windows with batch

Batch file without window border www.computing.net/answers/windows-xp/batch-file-without-window-border/169960.html

closing windows www.computing.net/answers/windows-xp/closing-windows/161402.html

IE 6 Close Window Button Not Work'n www.computing.net/answers/windows-xp/ie-6-close-window-button-not-workn/79878.html