1.

Solve : Batch File and DOS Window Problem?

Answer»

Hi
I have a batch file which is called hourly by winXP schedule. The batch file copies files for backup purposes and then writes to a log file.

Whenever it runs it opens a DOS window on screen which remains for about 10 seconds. How do I prevent the window opening? I want the code to run without any indication on screen.

Any ideas anyone.
Many thanks
[glb]Scriptham[/glb]



Code: [Select]
@Echo off

Set constLine=**********************************************

:: copies current log to logold WAS concatenates current log to logold
if exist H:\log.txt copy /B /Y H:\log.txt H:\logold.txt

:: Redirects xcopy instruction output to log file overwriting existing data.
xcopy c:\inetpub\wwwroot\cLIMS\*.* F:\dat1916\LIMS\c_wwwroot_copy /E /Y > H:\log.txt
xcopy c:\inetpub\wwwroot\Default.htm F:\dat1916\LIMS\c_wwwroot_copy /Y >> H:\log.txt

:: Returns error level reported, this should be zero.
echo Error Level Is %ErrorLevel% >> H:\log.txt


:: Adds time and date, adds end marker of ***, adds 3 spaces, concatenates logold to end of log
ver | date | find "current" >> H:\log.txt
ver | time | find "current" >> H:\log.txt
echo %constLine% >> H:\log.txt
Echo. >> log.txt
Echo. >> log.txt
Echo. >> log.txt
copy /B /Y H:\log.txt + H:\logold.txt H:\log.txt

:END
Look at the files properties and select run minimized. It will show on the task bar when run but will not open a window.
Bang on the money of course and thanks very much.
Once I USED the search string "xp batch files run minimized" (wording as you indicated) it was clear that the question had been dealt with before.

What I find peculiar is that you can set run to minimized in properties of a shortcut (pointer I presume) to the file but not in the properties of the file itself.

Ain't windows peculiar?

I have set this up and will know soon enough if it does the job.

Thanks again
[glb]ScriptHam[/glb]A batch file is really just an ASCII text document with a .bat extention, nothing else. There is nowhere to store information about how it is to be ran, as it is not a program as such. But yes, Windows is peculiar.Quote

There is nowhere to store information about how it is to be ran

Thats what PIF files are for. PIF means Program Information File. Thats why you can run them minimized, maximized, in a window, in DOS mode, prevent them from detecting windows, auto close when finished, etc.I have had time to use the advice given above and to test it. There appears to be a further problem as it runs but maximized.

When the batch files are run by me they run minimized; click on shortcut on desktop. When they are run from Win XP Schedule they run maximized.

All files involved (.bat and .txt log files) have been set to run minimized.

Now I really am stuck as the schedule program doesn't have a run minimized property that I can find.

Does anyone have any ideas please.

Many thanks
[glb]ScriptHam[/glb]See what the command start does (start->run: CMD and then start /?). Make another batch file, let's say startm.bat, where you will have only one line: start /min your_batch_that_should_be executed.bat (the one that you already have, not startm.bat). startm.bat should be called by WinXP scheduler. Make your adjustments now (to close itself when it finishes for example). Does it work now?Thankyou Viking for your advice. I made some tests as follows. I MAY have not understood your last sentence but one.
Quote
Make your adjustments now (to close itself when it finishes for example)

How do I adjust it to close itself?

Experimenting with minimized files produced the following:
Code: [Select]
@echo off
call C:\batch\simple_xcopy.bat
:: echo running xcopy_simple.bat


Test 0. Call -> Run -> CallSimple.bat
Result. Dos Window opens and closes. Otherwise OK

Test 1. Start /min -> CallSimple.bat
Result. Dos Window opens in taskbar BUT never closes, so number that are open increases. Also opens briefly on screen and closes. Otherwise OK.

Test 2. Click desktop shortcut to CallSimple.bat
Result. No Dos Window, otherwise OK.

Test 3. Adjust batch file to call "Shortcut to CallSimple.bat." And adjust schedule to call "Shortcut to Simple_xcopy.bat.". Should these be .bat.Ink files or similar?
Result. Proposed but not tested yet. Is it worth doing?

Is this more or less what you recommended? I hope it is. Does anything spring to mind regarding the accumulating DOS window entries in the taskbar?
I think this is very promising, shame its not more simple.
I look forward to hearing from you.
[glb]ScriptHam[/glb]
:)ADDENDUM to post above.

Test 3. Adjusted batch file to
Code: [Select]
start /min C:\batch\"shortcut to simple_xcopy.bat.lnk"
And adjusted schedule to call "Shortcut to CallSimple.bat". Although it just reads CallSimple.bat

Result. Seems to work in that log file entries are made and the DOS window makes a momentary appearance on screen and in taskbar. This is definitely progress. But it does not add empty lines to the log file, log.txt, the code to do this is
Code: [Select]
Echo. >> log.txt
Echo. >> log.txt
Echo. >> log.txt


Up until a few hours ago these three lines were added as the batch file ran.

In the properties of the SHORTCUTS I have set the DOS window to 1pxl*1pxl BUT it flashes on screen at natural or normal size. Can this be rectified please.

These are not severe problems but if there is a quick fix I would prefer it. The log file is difficult to read without.
Many thanks for help so far.
[glb]
ScriptHam
[/glb]


Discussion

No Comment Found