Showing posts with label executing external programs. Show all posts
Showing posts with label executing external programs. Show all posts

Thursday, June 13, 2013

Batch File to Kill a Process

Sometimes it is necessary to kill a process from a batch file. Here is a small script that shows you batch file to kill a process:
tasklist|find /i "process.exe">nul & if errorlevel 1 (echo No such process!) else (taskkill /f /im process.exe /t)
You need to replace process.exe with the name of your process to be killed. You can find additional information on the commands taskkill and tasklist on Microsoft website.
We kindly remind that Dr.Batcher is the best program to create batch file, both .BAT and .CMD, try it if haven't tried it yet. 

Monday, May 6, 2013

Difference between Call and Start

You may know that you can run a program or a batch file from your own batch file with the help of commands 'start' and 'call'. Both of them are used quite often, but what's the difference between them?
'Call' command pauses the execution of your batch file until the end of working of the called program or script. You can see it by creating a test batch file with a single 'pause' command. Save this test script as 'tst.cmd' and create batch file with text 'call tst' (no quotes). You'll see that your batch file waits for the end of execution of tst.cmd.
'Start' command starts the program or script in independent mode.  Change 'call' in your batch file to 'start'. You'll see that the main batch file closes its window while 'tst.cmd' is still running.
We kindly remind that Dr.Batcher is the best program to create batch file, both .BAT and .CMD, try it if haven't tried it yet. 

Wednesday, August 24, 2011

Installing Many Programs at Once

It takes a lot of time to install different software on the users' workstations. It is much easier to run a single batch script created with the award-winning batch files editor and install all these programs immediately. The script will look like this one:
@echo off
start /wait "" "C:\Install\setup1.exe"
start /wait "" "C:\Install\setup2.exe"
start /wait "" "C:\Install\setup3.exe"
start /wait "" "C:\Install\setup4.exe"
start /wait "" "C:\Install\setup5.exe"
It is not hard to change the paths to the installation EXEs and their names. But to simplify the installation process you should search for command-line parameters of popular installation engines (InnoSetup, NSIS, Windows Installer etc.). These parameters should let you install software in 'silent' mode and specify destination folder, components to be installed and other settings.

Saturday, July 9, 2011

Script for 'Remote Execution' of Programs

It is useful sometimes to download a program from a remote server and run on the computer where the batch script is running. It is not so hard to implement it:
title Loading program... Please wait...
@echo off
net use w: \\192.168.x.x\a1 > nul
echo "1. Disk connected"
cd d:\
d:
md 123
cd d:\123
md Program
copy w:\Prg.exe d:\123\Program\Prog.exe > nul
echo "2. File updated"
start d:\123\Program\Prog.exe > nul
echo "3. Run programm"
net use w: /delete > nul
echo "4. Disk disconnected"
exit

You can change this batch file with help of our award-winning batch files editor. Hope you'll find this example useful.

Sunday, May 8, 2011

Search for Running Process and Start It if It Is not Found

It is quite a common task to start some processes in an automatic way. Of course we usually have no need to run many instances of the application simultaneously, thus we have to check running processes first. Fortunately, batch files are pretty useful in this case and let us solve the problem in a fast and simple way. The solution will look like:
tasklist | findstr /i yourapp.exe 1>nul || start "" "C:\Program Files\Megacorp Inc\yourapp.exe"
You can easily modify this single-line script with the help of our award-winning batch file editor or send your questions and suggestions to us.

Sunday, April 17, 2011

How to Answer Y/N to Console Program from Batch File


Sometimes it is necessary to answer 'Y' or 'N' to a console program during the execution of a batch file. If your file is running under a user's sight, it causes no problems, but if you need to run it in a completely autonomous mode, you have to find a solution.
The solution is really simple: you should just write 'echo Y | ' in your batch file, where the name of a program that wants to know your decision is. Sometimes you should type 'YES' or 'NO' instead of short forms of 'Y' and 'N'. So read carefully the program's manual before passing answers to it.

Translate