Archive for September, 2009

Create Batch File to Start or End Window Services

We all want to tweak or windows systems to the extreme to get the quickest, most powerful system possible. Many people will disable multiple window services manually before game playing. What a pain!
Many times people forget what the services do or forget to restart the important ones. Services can be easily changed by creating batch [...]

Creating Batch File Processes in Photoshop

To begin this process you need to create an action. If you don’t know how to do this or never used Photoshop’s actions before, I’ll explain it. First you must create a new action from the actions menu, give it a name and hit the record button. Photoshop will now memorize everything you do in [...]

DOS Batch FTP - Simple - FTP script and batch in a single file

Embed FTP script into a batch script. Add this line at the beginning of the FTP script:
@ftp -i -s:”%~f0″&GOTO:EOF
The “FTP -s:ftpscript.txt” option executes a FTP script wheres “%~f0″ resolved to the name of the running batch file. “GOTO:EOF” ends the batch script and makes sure the FTP script doesn`t run as part of the [...]

Wait, Sleep, Hold - :sleep

The :sleep function puts the batch execution on hold for a certain amount of second.
:sleep -– waits some seconds before returning
::     — %~1 – in, number of seconds to wait
FOR /l %%a in (%~1,-1,1) do (ping -n 2 -w 1 127.0.0.1>NUL)
goto :eof

Get THIS computers IP address - :getIP

The getIP function filters the IP address from the ipconfig command output and returns it to the caller.
Code
:getIP — return THIS computers IP address
::     — %~1 - out, IP
SETLOCAL
set ip=
for /f “tokens=2,* delims=:. ” %%a in (’”ipconfig|find “IP Address””‘) do set ip=%%b
( ENDLOCAL & REM RETURN VALUES
IF “%~1″ NEQ “” (SET %~1=%ip%) ELSE (echo.%ip%)
)
goto :eof
Test [...]

OSQL.EXE - Run SQL script from DOS Batch - SQL script and dos batch script in one file, the One-File Solution

Embedding SQL script within a batch script is just as easy. The following batch script executes itself in SQL context. The trick is the GOTO command in the first line of the script. When executing GOTO START in batch context than the command processor will jump to the label “:START” and [...]

DOS Command Index

ASSOC    Displays or modifies file extension associations.
AT    Schedules commands and programs to run on a computer.
ATTRIB    Displays or changes file attributes.
BREAK    Sets or clears extended CTRL+C checking.
CACLS    Displays or modifies access control lists (ACLs) of files.
CALL    Calls one batch program from another.
CD    Displays the name of or changes the current directory.
CHCP    Displays or sets the [...]

DOS Batch - Find and Replace - Search a file and replace all occurrences of a string with another string

This batch allows string substitution in a text file. It parses each line of a text file for a particular string and replaces it with another string.
I.e. To replace all occurrences of “Yellow Submarine” in “color.txt” with “uboot” and put the output on the screen run:
BatchSubstitute.bat “Yellow Submarine” uboot color.txt
Or
type color.txt|BatchSubstitute.bat “Yellow Submarine” uboot
Optionally pipe [...]

DOS Batch File - Progress - Show progress in batch using the title bar

Showing progress in the output window seems impractical in DOS batch, since there is no way to overwrite a previews output for an updated progress status during each progress tick. Using the ECHO command is not nice, screen content quickly scrolls out of sight. A practicable alternative may be to use the window TITLE for [...]

DOS Batch FTP - Get New Files Only - Ftp script to download only files that don`t exist in local folder

This batch connects twice to the FTP server. First time it retrieves a list of files on the FTP server. This list is being trimmed to contain only files that don`t already exist locally. The files in the trimmed list are then downloaded during a second connection.  Note: Since all files are passed into the [...]