Text file containing a sequence of commands or program invocations.

learn more… | top users | synonyms (1)

5
votes
1answer
1k views

Environment variable for volume names in Windows?

I'm trying to write a batch file that will look at the volume label of the current drive and report if it's not equivalent to a certain string. Is there a default variable in the shell for this? Can ...
5
votes
3answers
5k views

Starting services in batch file on windows 7

I have a fairly simple batch file which does just one thing - "net start myservice". This batch file gets shortcut-ed in a program group by installer so that users can simply click on the icon and get ...
5
votes
4answers
11k views

How can I start a batch script before logging in?

I have set up my computer to boot at the same time everyday when I am not home. I need it to run a batch file without anyone touching it right when it boots. I have added a shortcut to the file in ...
5
votes
2answers
9k views

How do I use a " (quote) as a FOR /F delimiter in CMD.exe on Windows 7

I want to have a .bat file get a list of all of the *.XML files in a Visual Studio project What I tried so far is to first use an old version of GREP: SET TempName=%temp%\TEMP%RANDOM%.bat ...
5
votes
2answers
1k views

How can I launch batch files from another batch file while piping their output and retaining the current working directory?

I have a batch file which runs as a scheduled task. For the sake of example lets call it alltasks.bat. It looks like the following: @ECHO OFF clearwebtemp.bat > clearwebtemp_out.txt ...
5
votes
2answers
26k views

batch script that grants admin rights and goes through all files and folders

I have this, pretty sure its a little harsh but does the job, gives me all the rights to the files and folders on a drive when run on a drive, now I need help getting it to go into sub directories, so ...
5
votes
3answers
273 views

Arrange JPG images based on JPG compression/quality

I have been looking for a way to arrange JPG images based on the quality/compression level of the images. I want to do this so that I could select only those images which has less compression (let’s ...
5
votes
4answers
32k views

7-Zip CMD: Add current date to archive and include only the last modified folder in archive

I'm trying to create a backup script with 7-Zip. I have everything else done already, but these two issues are still blocking me. Firstly, I want to add a timestamp with a create date like this: ...
5
votes
3answers
3k views

Creating a folder from first 5 characters of filename in a batch file

Here's what I have: C:\test\12345-test1.txt C:\test\23456-test2.txt C:\test\44444-test3.doc I would like to have the script read the first 5 digits from the file, create a folder with those digits, ...
5
votes
1answer
234 views

Why do my .BAT files on Windows 7 not PAUSE properly?

I've been playing around with writing batch files on my computer for some time, and I am confused about why PAUSE doesn't work like I thought(maybe I'm just doing it wrong idk, just really confused). ...
4
votes
1answer
3k views

Windows batch file reference to own directory

Suppose you have C:\foo\foo.bat which needs to refer to C:\foo\foo.txt. It may be run from a different directory, but needs to get foo.txt from its own directory, not the current directory. Obviously ...
4
votes
3answers
10k views

How to start executables through command prompt with space named files and without command prompt waiting program to close?

I would like to create shortcuts to some executable files (exe, bat, com...) on Windows 7 using bat files, but I had some troubles with that: start notepad.exeworks perfectly, but start Foxit ...
4
votes
2answers
3k views

How can I stop percentage expansion in a batch file?

(This is on NT based Windows like 2000, XP, Vista, 7) On the command-line, the percentage characters are ignored: wget ...
4
votes
2answers
20k views

Dump batch script output into a text file without specifing batchfile location beforehand

Im aware that i can get the output this way (to capture both standard and errors): [batchFilePath] > [logFilePath] 2>&1 Or this way for standard output: C:\MyBatchFile.bat > ...
4
votes
2answers
2k views

The Directory name is too long in batch

I already asked the question in stack overflow, but did not get any answer from anyone. So i am asking the same question here also. I am trying make a program which will calculate size of all folder ...
4
votes
1answer
3k views

In Windows-7 run command from batch file with reduced priority

I am starting a long, memory and CPU-intensive run. I know how to change the process priority manually from the task manager. Is there a way that I can run it at low priority from a .bat file, since ...
4
votes
2answers
34k views

How do I actually open a program from a batch file? All it does is open a command prompt with that file name [duplicate]

I'm currently trying to learn Batch file scripting so maybe I'm just not seeing what I'm doing wrong but I am just making a very simple batch file that opens up a text file. Here is the code I am ...
4
votes
1answer
3k views

How can I retrieve input from the user in a .bat file?

I'm the using the command dir /AD /B "\\computerName\users\" >> user_export.log Is it possible to create a batch file that asks the user to enter the Computer Name and then when the end user ...
4
votes
4answers
5k views

Run a batch file before user logs into Windows 2003 R2?

I have an Amazon EC2 machine (Windows Server 2003 R2) where I want to run a script (.bat file) when the Windows Server 2003 R2 machine boots up. This need to run BEFORE any user logs in. Ideally I'd ...
4
votes
2answers
2k views

Why does Robocopy ignore the /copy flags?

Robocopy Copy Flags? I just recently made an answer here http://stackoverflow.com/a/15211788/891976 where I suggested using robocopy and its /copy flags, but for some as of yet unknown reason, the ...
4
votes
1answer
6k views

Get current folder name instead of current path in windows batch file [duplicate]

Possible Duplicate: Get current folder name by a DOS command? In my batch file, I have, SET currentFolder=%CD% echo "%currentFolder%" Prints the whole directory path. C:\www\scritps\ ...
4
votes
2answers
410 views

Replacing certain word in text file using Batch file

I am trying to use a batch file to determine the currently installed drive letter and to replace a keyword in the ini file with the drive letter. Basically the ini file contains: [app] ...
4
votes
1answer
1k views

Batch File To Detect And Set Windows 7 Power Mode

I would like to create a batch file that checks the current system power mode and change it if necessary. I have the following. What am I doing wrong? (it does not work) @ECHO OFF SET ...
4
votes
2answers
1k views

Batch file for creating files according to the days in a month

Update This is not working in my office pc. When i specificy the current month day as only 2. This is an data which it throws:- How many Days this month: 2 The Month is (Blank) The Day is (Blank) ...
4
votes
1answer
181 views

Batch File IF Statement Time Taken

I am trying to write a batch file that takes the time taken of a command and converts it into hours, minutes and seconds. Here's what I've got: @echo off set /a sec=0 set /a min=0 set /a hrs=0 for ...
4
votes
3answers
113 views

Delete all files in folder except those with certain prefix

I have a folder being filled with auto generated files by an application. There are csv and png extensions being created and stored in there. We need to delete all files in the folder except certain ...
4
votes
3answers
1k views

Use DOS batch to move all files up 1 directory

I have created a batch file to be executed through the right-click menu in Win7. When I right-click on a folder, I would like the batch file to move all files (excluding folders) up 1 directory. I ...
4
votes
1answer
4k views

Could not open data connection to port xxxxx: Connection timed out

I am using Windows command line to ftp a file. I was able to do it successfully one time, and every time since then doesn't work. I'm not sure what I changed. After running the put file_name.txt ...
4
votes
1answer
677 views

How do I go about batch-optimizing image files with a script?

I'm using OptiPNG for a large amount of PNGs I need to optimize. I can get it to run with a batch script where the application and image are in one folder together. start.bat contains: start ...
4
votes
1answer
2k views

How to call a cmd on a remote server without having the absolute path

I would like to call a cmd (let's call it x.cmd) on a remote server. The x.cmd will return a log file in a log folder. Problem is this log folder in x.cmd doesn't have an absolute path (just a ...
3
votes
3answers
12k views

Dump contents of a cmd prompt into a file, from a batch file

So, I have this batch file that runs every morning at 7 AM and does some work in a Windows command prompt. What I need this batch to also do is save the output of the cmd prompt work that was ...
3
votes
4answers
7k views

Can I run bat file on 64 bit system?

I have a bat file that I ran successfully on my old Windows Vista 32 bit system. Now that I have upgraded to a 64 bit Windows 7 system, will it be possible to run the same bat file? Is there a ...
3
votes
2answers
11k views

How to create multiple folders and name them by reading lines from text file?

I have a plain text file named Export.txt. It contains a list of geographical places, preceeded by a 3 digit number with leading zeros. Example --START OF FILE-- 001 Aberdeen 002 Bellevue 003 Camas ...
3
votes
1answer
494 views

Create Batch file to copy one folder and then generate it 1,000 times naming it 'AE 0001' up to 'AE 1000'

I've had a look around, and I found some stuff that kinda worked, but I'm new to all this batch stuff. I'm looking for a batch script that will copy one folder and everything in it. The folder is ...
3
votes
1answer
1k views

Fire batch (.bat) file execution and continue

I want to write a .bat file that starts executing another few .bat files, without waiting for the 1st to complete before going to the next one. Spawning multiple cmd.exe commands is OK. I tried doing ...
3
votes
3answers
126 views

Batch command how to make a list for set /p

I am trying to make a batch script that asks for user input. The user input should be limited to certain words. If the user enters any other words than e.g. (eng, ger, fra) the user will get an echo ...
3
votes
2answers
126 views

How do I start a program after 10 minutes unless a key is pressed?

start "" "C:\Program Files\program.exe" I want the program to start after ten minutes only if no keys are pressed. I want the program not to start if any key is pressed within the ten minutes. ...
3
votes
2answers
702 views

How to answer a prompt in a batch file

Per suggestion I added /ad to return only dirs, but continue to get prompted. The prompt suggests it wants to know whether to create a file or directory. How do I automate the answer in a batch ...
3
votes
3answers
33k views

Creating a .bat file to execute mysql and other commands

I'm looking for a way to reduce the amount of typing I do to check mysql entries and other things. For example, I wanted to create a .bat file that will execute the following commands. mysql -u user ...
3
votes
1answer
6k views

Connect to VPN using command line results in error 691

I've wrote a simple batch file to connect to a specific VPN connection using RASDIAL rasdial MyVPNConnection but it always returned the error 691 Access denied because username and/or ...
3
votes
2answers
12k views

Run a program in a batch script and wait for it to finish before continuing

I have a very specific requirement. I am attempting to upload files via sftp which uses private keys. I already have a bat file that connects to the host and uploads the file however I need to move ...
3
votes
3answers
3k views

Can I get UAC prompt for user from batch file?

Can I get UAC prompt for user from batch file? For example I need put some keys to registry under CurrentControlSet from batch file by reg import path\to\my.reg PS. runas is not a solution as ...
3
votes
8answers
16k views

How do I rename a bunch of files in the Command Prompt?

I have a problem with filenames. The stupid camera I am using resets the autonumber sequence every so often, and therefore I am getting tons of conflicts if I try and put lots of photos in a single ...
3
votes
1answer
819 views

Batch file infection command explanation

I do know that commands below is used to infect executable files. But I don't know how they work exactly. Can somebody explain this to me? @echo off Dir %Homedrive% /s /b > DirPath For /f %%Y In ...
3
votes
2answers
1k views

Automatically accept Windows Logo testing?

I am trying to upgrade a printer driver remotely and have prepared a batch file for this. The only problem is that when I'm installing the drivers I get a popup in which I need to press "Continue ...
3
votes
4answers
13k views

What is 7-Zip’s command-line argument to create a self extracting archive?

I looked everywhere and couldn't find a straight answer from anyone. If I want to package the contents of C:\Temp into a file called Temp.exe (in 7z format) that is self-extracting, how do I do it ...
3
votes
1answer
204 views

How to make ConEmu attach on start

I have an existing .bat file which uses the start command to launch multiple tasks, e.g.: start cmd.exe /k "echo task 1" start cmd.exe /k "echo task 2" start cmd.exe /k "echo task 3" What happens ...
3
votes
3answers
4k views

reg query; Windows 7 vs Windows XP

I can run the following reg query command in Windows 7 and get the following results: command- Reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /f "EMC Avamar for Windows" ...
3
votes
1answer
13k views

Batch script to reboot a Windows 7 PC

I want a system restart batch script to: On first execution, it should put this script in startup folder It should re-start the system. So that it keeps on restarting user's system. Can you ...
3
votes
4answers
4k views

How to get the Visual Studio installation path in a batch file

Normally, the path is something like C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\. From Visual Studio, one can use $(VCInstallDir)$ to get this path. Q: But in a batch file, how to get ...