Call vs Start: Reasons why your batch script might not be writing output to file

If you are calling another batch script from your source script you need to call it by preceding keywords Call or Start before the script name.
But here also there is a catch:
Start will open a new cmd window and execute command there and will not write the output in external text file if you have redirected it there:
For example if you execute BatchScriptSource.bat it will not write anything in SomeTextFile.txt although it will be created.
Contents of BatchScriptSource.bat
start BatchScript.bat >> SomeTextFile.txt 
Contents of BatchScript.bat
tasklist 
Output Using Start:

On the other hand Call will execute BatchScript.bat in the scope of same cmd session/window where BatchScriptSource.bat is being executed and will execute commands sequentially and write the output in SomeTextFile.txt as expected.
Contents of BatchScriptSource.bat
call BatchScript.bat >> SomeTextFile.txt
Contents of BatchScript.bat
tasklist 
Output Using Call:

Comments

Popular posts from this blog

Enabling fixed Sidebar for blogger Contempo template for screen sizes smaller than 1440px

Adding copy to clipboard button to every google code prettify pre blocks in blogger

Query to Expand and List All logins within a SQL Server Group