Saturday, January 5, 2013

Why Is There No Percentage Mark in the Line Seen on the Screen?



In batch files percentage mark is used to indicate variables, or variable environments, or internal variables of the BAT-file. So, if you’d like to see percentage mark on the screen, you just need to use it twice: for example, “echo This day performed 0.25%% of the whole project”. By the way, is not the only symbol that has a special meaning in BAT files. Such symbols also include “>”, “<”, etc. They can be displayed on the screen with the help of combinations “^<”, “^>” (i.e. you put a tick before the symbol).

Wednesday, December 19, 2012

How to Convert Batch File to EXE

Despite the fact batch files are quite useful for different purposes, it is better sometimes to convert them into executable ones. Today we will learn how to convert batch files to EXE. The easiest and fastest way to convert it is utility Dr.Batcher. It offers a special wizard that lets you convert batch file to EXE in several clicks.
1. Download Dr.Batcher and install it on your computer
2. Start Dr.Batcher and open the batch file you want to convert.
3. Choose ‘Tools’ -> ‘Compile EXE File…’. Follow the wizard instructions.
4. Enter the output file name, choose application type and security options. Check ‘Console’ to create application that will show console output during the batch file execution, or choose ‘Invisible’ to hide the console output. Check ‘Protect batch file and additional files to pervert reverse engineering’ to encrypt the output file. Click ‘Next’.
5. Choose the additional files your script needs while execution. It might be some external applications (for example, zip for backup scripts), other scripts or any other file. Click ‘Next’.
6. Click ‘Next’ to create the executable file.
7. Click ‘Run the created file’ to test the converted EXE or ‘Finish’ to exit the wizard.

Friday, September 7, 2012

New Version of Dr.Batcher Offers Backup Script Wizard

The new version of Dr.Batcher, the award-winning tool for creating and editing batch files, comes with support for creating full-featured backup and restore scripts in a few clicks.
Version 2.2 of Dr.Batcher, a powerful tool for batch files creation and editing designed both for advanced users and newbies, offers brand new Backup Script Wizard. Now one can create compressed (ZIP, CAB archive formats supported) or uncompressed backups with the help of batch scripts, and restore them. All compressed backups can be protected with passwords, also the level of compression is changeable.
It should be noticed that the new version of Dr.Batcher comes with multi-document tabbed user interface. Now one can easily move from one batch file to another during programming them and make changes in many files without opening and closing each of them. Dr.Batcher can automatically load all recently opened files, so user doesn’t have to remember all of them.
Among other changes, in Dr.Batcher 2.2 one can meet support for automatic adding the copyright message on the top of the script, support for auto-saving scripts after the specified period of time, updated settings.
Dr.Batcher still provides users both with professional script editor and simple editor for those who don’t know batch files syntax well. The application comes with support for dozens of most commonly used DOS and Windows commands, also users can extend the list by writing their own XMLs with commands descriptions. While editing a batch file, user can switch between visual editor (Simple mode) and text editor (Professional mode) any time he wants.

Saturday, September 17, 2011

Useful Script for Network Backup

Here is an interesting backup script from one of our customers. It requires an external tool to be run, but allows to perform backup from many computers over the network:
@echo off
@set dircmd=/b
set folder=Documents and Settings
for /F "tokens=1 usebackq delims==\ " %%i IN (`net view`) DO (
echo Start copying %%i...
start /wait /min /high robocopy.exe "\\%%i\C$" X:\backup\uim\%%i\C *.doc *.xls /S /R:1 /W:120 /XD RECYCLER batmail "Application Data" game* "Default User" "ÿáí½«¡δ" "Local Settings" windows winxp wxp w2k winnt "Program Files" Temp NetHood Recycled Install "The Bat!" "System Volume Information" readme /XF "~*.*" readme /XJ /XO
start /wait /min /high robocopy.exe "\\%%i\D$" X:\backup\uim\%%i\D *.doc *.xls /S /R:0 /W:1 /XD RECYCLER SCANJET batmail "Application Data" game* "Default User" "ÿáí½«¡δ" "Local Settings" Temp Recycled Install readme/XF "~*.*" "System Volume Information" readme /XJ /XO

Wednesday, September 14, 2011

Creating a New User Account via Batch Files

Q: I need to write a batch file that creates a new user account. The account's name and password should be passed as parameters like batch_file name pass. What should I do?

A:
Start Dr.Batcher and type the following script:

@echo off
if "%~2"=="" goto error
if "%~1"=="" goto error
net user %~1 %~2 /add
goto :EOF
:error
echo Usage: %~0 user password

That's all!

Friday, September 9, 2011

Removing Unnecessary Trailing Spaces

Imagine: we have a variable with some string data, and we have to remove unnecessary spaces from the end of this variable. The code below shows how to solve this problem:

@echo off
setlocal
set "a=111 222 "

:loop
set /a n+=1
for /f "tokens=%n%" %%i in ("%a%") do (
if not "%%i"=="" set b=%b%%%i && goto:loop
)

set a=%b:~0,-1%
set b=
echo "%a%"


Of course, you have to change this code a bit before using it. You can do it with the help of our award-winning batch files editor. Hope you'll find this example useful.

Sunday, August 28, 2011

Sorting Web Pages Archive

The task is to sort the archive of different Web documents.

There is a plenty (about 5 thousands) of files named the following way:
number(3-6 digits)_name_.zip(jar,sis)
And the same amount of images in 'Screens' folder:
number(3-6 digits).jpg(gif,png)
Alse there are Web pages in 'Html' folder:
number(3-6 digits).htm(html)
Is it possible to write a batch script that creates folders named after a file and move there a file, a picture and a Web page? ZIP archive should be also extracted there.


The batch script to solve this task looks like this:

@Echo Off
Set ArcDir=c:\archives
Set ScreenDir=c:\screens
Set HTMLDir=c:\html
Set OutDir=C:\
For %%A In (%ArcDir%\*.zip %ArcDir%\*.jar %ArcDir%\*.sys) Do (
md "%%~nA">Nul 2>&1
If /I "%%~xA"==".zip" (
pkzip -extr=up "%%A" "%OutDir%\%%~nA">Nul 2>&1
) Else (
Copy /y "%%A" "%OutDir%\%%~nA">Nul 2>&1
)
Copy /y "%ScreenDir%\%%~nA.*" "%OutDir%\%%~nA">Nul 2>&1
Copy /y "%HTMLDir%\%%~nA.html" "%OutDir%\%%~nA">Nul 2>&1
)

Hope you'll find this example useful. You can modify this script with the help of our batch files editor called Dr.Batcher.

Translate