The Command Line Is a Useful Heritage from MS DOS

     

Summary. The command line plays a key role in computer work optimization (automation). MS DOS commands are still used in administering of huge networks as well as home personal computers. The secret of their popularity is in simplicity and convenience of their usage. Several lines typed in cmd.exe or saved in *.bat files – and you have a fully-functioning program, which saves you from boring routine actions. The article describes 5 examples of command line use, gathered from different sources. They can be used both at work and at home. 

1. How to identify whether the process is launched and to start it only if it is NOT?

In the first line, the whole list of launched processes is placed into a temporary file temp.txt. In the second line, a line, corresponding to the required process tcrecv, is being searched in this file. In the third line, in case the process is not found, the label, linked with the required process, is launched. 

============================================
tasklist /fi "imagename eq tcrecv.exe" >temp.txt
find "tcrecv" temp.txt
if errorlevel==1 start C:\"Program Files"\tc-recv\tc-recv.lnk /b
============================================

2. To set Internet connection with the help of the command line:

rasphone -d "Beeline gprs"

To disconnect: 

rasphone -h "Beeline gprs" 

3. To hibernate and to close some programs before this. 

The last line is hibernation itself. Some programs (for example, birthmil) can't "stand" hibernation, and when computer is switched on, they show error messages and close. So, it's useful to hibernate through the bat file, and to plan program launch through AutoClickExtreme, which allows in Task Manager to set the launch condition "Come out of hibernation (standby mode)" 

============================================
taskkill /im dvbdata.exe
taskkill /im "Toddler Keys.exe"
taskkill /im dmaster.exe
taskkill /im birthmil.exe
taskkill /im tcrecv.exe
rundll32.exe powrprof.dll,SetSuspendState
============================================
To switch your computer off use this command:
%windir%\system32\shutdown.exe -s -f -t 01

4. To archive (back up) files (in case WinRar is installed)

"%ProgramFiles%\WinRAR\rar.exe" a -ag_YYYY.MM.DD_HH-MM -ep1 "J:\AutoClickExtreme\app_home.rar" D:\!Naclad\app

Date, hour and minute are added to an archive name, -ep1 removes form the archive full path to the archived files. Such archivation can be planned for weekends in AutoClickExtreme Task Manager; in order to avoid archivation of files, opened for editing. Or you can take the 1st example code, to prevent archivation when some processes are launched. 

5. To change printer on default. 

cscript %windir%/system32/prnmngr.vbs -t -p "Canon iP1600"

It's useful if you often change printer settings, for example, change from rough draft black and white two-sided printing to good quality color one-sided printing. Create a copy of your printer through printer installation (Start =>Settings => Printers and Faxes =>Add a printer) and in the printer properties set on default what you need (Properties =>Options=>Default Document Options). Thus, you'll have 2 printers in one system, in reality they lead to one and the same device. To change a printer on default quickly, create 2 bat files with setting on default for 2 different printers: so you can start the first bat file for printing one type of documents, and the second – for the other type. 
The 5th example can be used for "distant" printing. If you have to take printed documents to another floor, and you have access to the printer there, you can make a bat file switching to the distant printer. Thus, the documents will be printed where they are needed. 

cscript %windir%/system32/prnmngr.vbs -t -p "\\d055048\HP LaserJet 5P"

        All these examples can be placed in text files and named with bat extension. They can be used as ordinary programs and placed into AutoPlay in a task scheduler (you can use either the standard one of Windows or a more advanced, such as AutoClickExtreme). It's advisable to use command line (Start=>Run=>Cmd.exe=>Enter) for the first time testing of these examples.

You can also read:

Pixel Control - a New Range of AutoClickExtreme Opportunities

Shortfalls of AutoClickExtreme

How AutoClickExtreme Works