So don't forget that Dr.Batcher lets you compile your batch scripts into Windows executables!
Sunday, May 29, 2011
How to Start a Batch Script in Background Mode
So don't forget that Dr.Batcher lets you compile your batch scripts into Windows executables!
Tuesday, May 24, 2011
Deleting a Registry Branch at the Given Time
at 00:36 reg delete HKLM\Software\MyPrg /f
Don't forget to change the time and registry branch before using this solution. You can use our award-winning batch file editor to change this small script in according to your needs.
Don't forget to change the time and registry branch before using this solution. You can use our award-winning batch file editor to change this small script in according to your needs.
Sunday, May 22, 2011
Generating a Sequence of Random Numbers in Batch Files
It's sometimes necessary to generate a sequence of random numbers in a script. In this blog you can find some posts on dealing with random numbers, still this question has never been discussed. Here is an example that shows how to generate and print on the console 99 random numbers. You can use our award-winning batch file editor to redirect the output to a text file and then build a plot in Excel to check these numbers being really random.
Friday, May 20, 2011
Useful Update for the Previous Blog Post
After publishing the previous blog post, we have received a message with the script that lets one avoid printing all the details of pinging many IP addresses and saying which of them are available instead. It is really a handy and useful script and we decided to share it with the readers of our blog.
@echo off
for /l %%i in (1,1,255) do (
ping -n 1 192.168.1.%%i | findstr "TTL=" 1>nul && (
echo 192.168.1.%%i is UP
) || (
echo 192.168.1.%%i is DOWN
)
)
@echo off
for /l %%i in (1,1,255) do (
ping -n 1 192.168.1.%%i | findstr "TTL=" 1>nul && (
echo 192.168.1.%%i is UP
) || (
echo 192.168.1.%%i is DOWN
)
)
Tuesday, May 17, 2011
Another Way to Ping Many IPs at Once
We have already discussed how to ping the given list of IP addresses. Now let's look what we can do if this list isn't placed in a text file. As usual, the solution is very simple:for /L %%i in (1, 1, 255) do ping 192.168.1.%%i
Of course, you have to use your own subnet mask instead of 192.168.1 in the example above. Hope this small script will help you to write your own powerful batch files.
Sunday, May 15, 2011
Checking File Size in Batch Files
It's sometimes necessary to check the size of a given file. For example, if you are to delete too big files on your hard drive or split single file into many parts. As usual, batch files are powerful enough to perform such task. The example below shows how to check batch file size (file is called 1.txt) and exit the script if the size is equal to 100 Kb.for %%a in (1.txt) do if %%~za EQU 102400 goto :EOF
You can use this example in scripts that you create with help of our award-winning program designed to write batch files.
You can use this example in scripts that you create with help of our award-winning program designed to write batch files.
Friday, May 13, 2011
A Small Quiz Script :)
There are lots of useful scripts already published on this blog. You can create even more of them with the help of Dr.Batcher. Now it's time for jokes. Let us introduce a small quiz script that can be useful to check whether you are lucky today. Hope you'll enjoy it:)@echo off
set i=0
echo Thinking of a number...
:rand
set nmb=%random%
if %nmb% GTR 10 goto rand
if %nmb% EQU 0 goto rand
echo Now you can try 3 times to guess the right one!
:enter
set /p "ent=Your number : "
set /a i=%i%+1
if %ent% EQU %nmb% (
echo You're lucky!
pause
exit
)
if %i% LSS 3 (
goto enter
)
if %i% EQU 3 (
echo Game Over:(
pause
)
set i=0
echo Thinking of a number...
:rand
set nmb=%random%
if %nmb% GTR 10 goto rand
if %nmb% EQU 0 goto rand
echo Now you can try 3 times to guess the right one!
:enter
set /p "ent=Your number : "
set /a i=%i%+1
if %ent% EQU %nmb% (
echo You're lucky!
pause
exit
)
if %i% LSS 3 (
goto enter
)
if %i% EQU 3 (
echo Game Over:(
pause
)
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.
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, May 1, 2011
Random Numbers Generator
As far as you probably know it is not so hard to generate random numbers with the help of batch files. But if you want to make sure that your number is unique among the given sequence of numbers, the task becomes a little bit more complicated. Here is a quite simple solution that can be modified with the help of our powerful batch files editor:

@echo off
setlocal
:try
set "rand=%random%%random%"
if "%rand:~6%"=="" goto try
1>nul 2>&1 type prevrand.txt | find "%rand:~0,6%"
if not errorlevel 1 goto try
echo %rand:~0,6%>prevrand.txt
As far as you can see, we use a special text file to store all previously used numbers. Of course, it's better to remove it after you have done all the work, whatever you need to do with the generated numbers. Hope you'll find this small random numbers generator useful.
Subscribe to:
Comments (Atom)
