PDA

View Full Version : DOS and Batch files


TJ_Tigger
01-12-2005, 08:24 PM
I am working on trying to launch an application not in association with AMS by using a batch file. I have no problem with launching the file, but in Win2k the command window remains open after the launch of the application and if you close the command window, the application launched by the command window also closes.

Does anyone have any suggestions on how to launch a program using a batch file and then be able to close the command window that the batch file used but have the launched application remain open.

Thanks

Corey
01-12-2005, 08:43 PM
Sure there's a couple ways. You have to mess around and figure which one is best. One way is to pipe the output to a file by using a > character. Another way might be to terminate it from AMS. Also if you create a shortcut to a batch file you can set the chortcut to run the console window minimized. So if you have an exit command in your batch file, the user would never see it.

Anyhow to make it simple start here and see if this is all you need:

http://www.computerhope.com/issues/ch000320.htm

Let me know if that doesn't work and we'll try something else. :)

TJ_Tigger
01-12-2005, 10:50 PM
Thanks Corey, I will give it a try, but I think it is a problem with 2000 and xp where it will not exit the command window if it is still running the program. The product we are launching is a Java program.

I will try it tomorrow.

Tigg

Corey
01-12-2005, 10:56 PM
I'm certain there are ways to have the batch file window close in XP with the launched program still running. I've done it. We'll figure it out, although it may require a combination of steps.

For example what if you created a small .exe in AMS to kill the batch file window, and then launched that from the batch file after the java program? I mean that's obviously way too sketchy to be the best solution but it just illustrates that where there's a will there's a way. For sure you can run any batch file minimized by creating a shortcut to it, then right clicking on the shortcut and going into the properties and selecting "Run : minimized".

Lorne
01-13-2005, 12:48 PM
You could try adding these two lines to the end of your batch file so it will close automatically once the commands are done:

@echo off
cls

As for making cmd not wait for the application to terminate, you could try using the START command:

START <filepath>

Intrigued
01-13-2005, 12:52 PM
No need for anything fancy...just add these two lines to the end of your batch file and it should close automatically:

@echo off
cls

I thought that only works in Win9x?

Lorne
01-13-2005, 12:57 PM
I've edited my post a bit, but I think that works in XP as well. Not sure about NT (it's been a looooooong time since I've used NT).

csd214
01-13-2005, 01:04 PM
cls

Clear Screen?
Do you mean 'exit'?

Intrigued
01-13-2005, 01:30 PM
I've edited my post a bit, but I think that works in XP as well. Not sure about NT (it's been a looooooong time since I've used NT).

I tried quite a few yesterday... and found that there seems to be no way to do this at this time (maybe a 3rd party application or some guru M.S. agent will be of help though)

:eek:

:D

Intrigued
01-13-2005, 01:32 PM
Clear Screen?
Do you mean 'exit'?

Actually CLS I read is suppose to work on Win9x machines for example.

Lorne
01-13-2005, 04:17 PM
CLS, which clears the command console (a.k.a. DOS prompt).

AFAIK this is still required in XP when you're invoking the command prompt by executing a batch file.

Intrigued
01-13-2005, 04:33 PM
Lorne, last night I created a batch file (test.bat) and just had one line coded in:

START filepathandnameofprogramhere

It started up... I just could not find a way to close the command prompt from the batch file. ;-(

(The system is running Win XP Home, btw)

Corey
01-13-2005, 06:32 PM
Hi guys. Making a batch file run and go away without seeing it is in this example, see attached. When you run "runme" you won't see a thing hopefully but you will see a new text file appear next to your batch file.

Anyhow that's this, if this doesn't help your specific scenario Tigger, let me know and I'll show you a couple more methods. Bottom line, it's definitely do-able. The only question is can we get away with doing it this way or do we need to create code in our main AMS project to kill the DOS window too. Either way I remember doing this a few times for little utilities I've built in AMS and I always was able to get it working, so...

Intrigued
01-13-2005, 06:57 PM
Waitttt.. that's two files!

;)

:yes

Corey
01-13-2005, 07:07 PM
For the following to have any impact, you must say it like Edward G. Robinson:

What files? I don't know nothin' 'bout no files, See? Yeah... See? I didn't see nuttin'! See? Nuttin'! Yeah...

That's the official corporate response anyhow...

Intrigued
01-13-2005, 07:56 PM
lmao!

Jolly Good show!

csd214
01-14-2005, 03:27 AM
I don't recall the use of the Exit command (Corey ends his Batch.bat with 'Exit'; it's not needed with WinXP). I looked into my old batch files. It seems that the 'exit' was needed (Win9x) when the batch file was started from a DOS Prompt window. If I start the batch file from the Win environment, the 'exit' does not help. You HAVE to close the window manually.

Corey, the Runme.lnk with "Minimized" was great. On a Win98 machine the lnk file was automatically converted to a pif file (Program Information File), but the OS was not fond of "C:\Documents and Settings\Corey\Desktop\tigger" as the working directory. I don't think an Internet connection should help. :lol

The CLS command erases the screen (previous output to the screen) and does not close the command window (same functionality in all OSs).

Intrigued, try the syntax:
START /D"C:\Program Files\IrfanView" i_view32.exe

Once upon a time I created my installers with a bunch of batch files (I learned a lot from Symantec and other large companies). To have a "fancy" screen it was common to have commands like 'echo * * * * * * *'. To day we have SUF70 with themes. No, I don't want to revert to "those good old DOS days"…

Intrigued
01-14-2005, 12:43 PM
Alas, I do not have ifranview installed anymore on any of my systems. However, I did try a variation of that code csd214 for the notepad.exe in the Windows directory to no avail. :huh

csd214
01-14-2005, 01:13 PM
This should work for Notepad:
START /D"C:\Windows" notepad.exe

Type 'help start' at the command prompt to see the Start syntax.

DavidM
12-19-2005, 06:24 PM
CD C:\Program Files\Windows Media Player\
START mplayer2.exe && EXIT

Eagle
12-20-2005, 11:04 AM
Here Ya Go Tigg..

and All good things for Everyone during the Festive Season:

This is a great third party , totally free to distribute program
to create a new proccess and run with window hidden.

I've cooked up an example on how to use this little beauty,
I've trimmed down the original program for ya..less overhead.

Also makes use of a 'no actual batch file method'

Merry Xmas to all... :)

does it run on 64Bit ..You betcha sweet bippy :yes :)

TJ_Tigger
12-20-2005, 11:40 AM
Thanks Eagle. I will play with that to see if it works with my application.

Tigg

Eagle
12-20-2005, 11:43 AM
NP..it can do heaps, this one..check out the html info file in autoplay\docs\

I've been using it for a while now for differing purposes and never let me down,
just need to fiddle with the /WAIT command for the program and or AMS to get
some occassional tricky stuff working aok.

Intrigued
12-20-2005, 06:17 PM
Nice find Eagle. Saves me from finishing one of my .exes!

Woot!

windyboy
07-31-2007, 05:23 AM
Hi I just registered to post a thanks for the suggestion i just used

CD C:\Program Files\Windows Media Player\
START mplayer2.exe && EXIT

succesfully. I needed this to modify access to BT's
Mobile Express software as I need it to run after a batch file called it.

BT keep releasin updates which wipe the connection settings and my batch file replaces our custom files.

Thanks for a good fix guys!!!

Intrigued
07-31-2007, 07:37 PM
Hi I just registered to post a thanks for the suggestion i just used

CD C:\Program Files\Windows Media Player\
START mplayer2.exe && EXIT

succesfully. I needed this to modify access to BT's
Mobile Express software as I need it to run after a batch file called it.

BT keep releasin updates which wipe the connection settings and my batch file replaces our custom files.

Thanks for a good fix guys!!!

I just had a conversation about this at the company I work for, that we should make sure our install set is not doing this sort of thing.

It's a good point more company's would be wise to take into a account when completing their install sets.

:yes