bat

How to change the icon of .bat file programatically?

I'd like to know what's the way to actually set the icon of a .bat file to an arbitrary icon. How would I go about doing that programmatically, independently of the language I may be using. ...

Easy installation method for windows/ Batch Reference needed?

I have a bunch of files that I need to be able to transport and install quickly. My current method for doing so is moving a flash drive with a readme file of where stuff goes whenever I need to move stuff, which is rather inelegant and cumbersome. My idea for a solution would be to write up a quick script to move files around that I cou...

What is a good windows batch scripting reference guide?

I have found a few guides to be incomplete and hard to follow. Can I get a recommendation for a couple good guides on this subject? ...

Batch file to "Script" a Database

Is it possible to somehow use a .bat file to script the schema and/or content of a SQL Server database? I can do this via the wizard, but would like to streamline the creation of this file for source control purposes. I would like to avoid the use of 3rd party tools - just limiting myself to the tools that come with SQL Server. ...

How to Pass Command Line Parameters in batch file

I needed to pass id and password to a cmd (or bat) file at the time of running rather than hardcoding them into the file. Here's how I do it. echo off fake-command /u %1 /p %2 Here's what the command line looks like: test.cmd admin P@55w0rd > test-log.txt The %1 applies to the first parameter the %2 (and here's the tricky part) ap...

How can I write a bat file to download only new FTP files?

Hi, I would like to use the built in windows ftp application to download some files on a periodic basis using a scheduled task and a .bat file. However I don't want to download the whole directory each time just the files that have changed or are new. Can this be done or do I need to write .NET application or the like? UPDATE: After ...

Long commands split over multiple lines in Vista/DOS batch (.bat) file

How do I make long commands go over multiple lines in a Vista/DOS batch file? ...

Batch script to copy newest file

I need to copy the newest file in a directory to a new location. So far I've found resources on the forfiles command, a date-related question here, and another related question. I'm just having a bit of trouble putting the pieces together! How do I copy the newest file in that directory to a new place? ...

How do I get the result of a command in a variable in windows?

I'm looking to get the result of a command as a variable in a Windows batch script (see how to get the result of a command in bash for the bash scripting equivalent). A solution that will work in a .bat file is preferred, but other common windows scripting solutions are also welcome. ...

How do I protect quotes in a batch file?

I want to wrap a perl one-liner in a batch file. For (trivial) example, in a unix shell I could quote up a command like this: perl -e 'print localtime() . "\n"' But DOS chokes on that with the helpful Can't find string terminator "'" anywhere before EOF at -e line 1. What's the best way to do this within a .bat? ...

How do I implement quicksort using a batch file?

While normally it's good to always choose the right language for the job, it can sometimes be instructive to try and do something in a language which is wildly inappropriate. It can help you understand the problem better. Maybe you don't have to solve it the way you thought you did. It can help you understand the language better. May...

Windows batch files: .bat vs .cmd?

As I understand it, .bat is the old 16-bit naming convention, and .cmd is for 32-bit Windows, i.e., starting with NT. But I continue to see .bat files everywhere, and they seem to work exactly the same using either suffix. Assuming that my code will never need to run on anyhting older than NT, does it really matter which way I name my ba...

How can I unzip the newest file in a directory in a BAT file?

I am working on a build system. The build system posts the results as a zip file in a directory. Unfortunately I have no easy way to know the name of the zip file, because it is timestamped. For the next operation, I must decompress this zip file to some specific location and then do some more file operations. I guess I could change ...

How to create empty text file from a batch file?

Can somebody remember what was the command to create an empty file in MSDOS using BAT file? ...

Bat file to run a .exe at the command prompt

Hi, I want to create a .bat file so I can just click on it so it can run: svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://localhost:8000/ServiceModelSamples/service Can someone help me with the structure of the .bat file? ...

Weird scope issue in .bat file

I'm writing a simple .bat file and I've run into some weird behavior. There are a couple places where I have to do a simple if/else, but the code inside the blocks don't seem to be working correctly. Here's a simple case that demonstrates the error: @echo off set MODE=FOOBAR if "%~1"=="" ( set MODE=all echo mode: %MODE% ) else (...

How do I run robocopy without copying extended attribute information?

Greetings, I've got a bat script which copies certain information from a computer onto a USB hard drive using Robocopy. The hard drive is FAT formatted and therefore doesn't support directories with extended attributes, leading me to robocopy error 282 as described here. How do I tell robocopy to copy all the attribute information EXC...

What is the best way to send an email from a batch file?

I have a nightly batch job that can tell if it has failed. I want it to send me an email, possibly with an attachment when it does. How can I send an email from a Windows Batch (.bat) file? ...

Windows Batch File - ENABLEDELAYEDEXPANSION query

Hey All, Having read an existing post on stackoverflow and done some reading around on the net. I thought it was time to post my question before I lost too much hair! I have the following code within a batch file which I double click to run, under Windows XP SP3: SETLOCAL ENABLEDELAYEDEXPANSION ::Observe variable is not defined SET t...

Running a CMD or BAT in silent mode

How can I run a CMD or .bat file in silent mode? I'm looking to prevent the CMD interface from being shown to the user. ...