Archive for September, 2009

Difference Between COPY and XCOPY

COPY does a shallow copy (doesn’t recurse into sub directories) while XCOPY has the option to do a recursive copy which will copy all files and sub folders within the target folder that you are copying. if you’re just copying one single file, either one will suffice.

Create a Disaster Recovery Copy of Your Files in Real Time

1) Create a batch file with the following code:
xcopy /d /s /y “\\networkPC\e$\foldertobackup” “E:\BackupFolder”
2) Create Windows Scheduled Task
3) Point Windows Scheduled Task to the batch file created in Step 1
4) Make Windows Scheduled Task to run “Daily” starting from 5 am in the morning (before start of the working day)

Scheduled Windows (PC) Restart Using DOS command (shutdown.exe)

1.Create a batch file “restart.bat” with the following code shutdown -r -t 60 -c “Rebooting computer”
2.Create a scheduled task that would execute restart.bat

How to execute a “batch file” using SQL Server 2005?

One method is with a SQL Server agent CmdExec job step. Another is via xp_cmdshell. If you choose to use xp_cmdshell, be sure you fully understand the security implications and don’t grant direct execute permissions on the proc.
How to: Create a CmdExec Job Step
By default, only members of the sysadmin fixed server role can create [...]

Start .EXE, .BAT or .COM file from batch file

If you want the start command to run the MENU.EXE file that’s located in say the root directory of drive C:, you would type:
start c:\menu.exe
If you want the start command to run the MENU.BAT file that’s also located in the root directory of drive C:, you would type:
start c:\menu.bat
If you had a MENU.EXE, MENU.BAT [...]

DOS/Batch Commands/Functions Descriptions

DEL and ERASE
In Windows NT, the DEL and ERASE commands are much more powerful than they are in other versions of MS-DOS and Windows. Although the basic syntax remains the same, Windows NT offers several switches that allow DEL to behave like the DELTREE command. Using the appropriate switches, it’s also possible to delete files [...]

Run a specified program only on certain days at boot time.

This demo makes use of two tricks: It reads a custom INI file, and it puts the current day into the environment.
@echo off
:: This batch file allows you to run programs on certain days.
:: Have this TODAY.BAT program CALLed from your AUTOEXEC.BAT.
:: TODAY.BAT will read entries in a TODAY.INI file you must make.
:: The entries [...]

Have your batch file to anser “Do you really want to do this?” prompt.

If you find yourself trying to automate the deletion of files, the formatting of floppies, or do anything else REALLY INTERESTING, you’re going to hit a spot where everything stops and you get asked “Are you sure?”. Sometimes you can pass a “/y” on the command line (like the COPY command) to override this, but [...]

Get user input from batch file

Sure, you’ve done it, but can you do it without having to hit a Ctrl-Z, without ANSI, without a debug script, and without a separate “set” file?
rem  This batch file gets a character or word of user input and
rem  returns it in the environment variable VALUE. Two tricks are
rem  used to accomplish this:
rem
rem  (1) The [...]

Batch file to Stop/Start Service

I would like to restart a service by using a service account in batch. The batch file will need to read over 300 file services from a text file and stop the service. A second file will start the service in the same manner.
You can do this using a combination of for /f and “net [...]