Questions tagged [batch-file]

A batch file is a text file containing a series of commands that are executed by the command interpreter on MS-DOS, IBM OS/2, or Microsoft Windows systems.

Filter by
Sorted by
Tagged with
1 vote
4 answers
6k views

How to make a batch file a task switcher?

How to make a batch file a task switcher? With windows XP and Windows 7 batch files... The batch file is: cls @echo off echo 1 start /normal c:\windows\system32\taskmgr.exe echo 2 pause ...
Joseph's user avatar
  • 111
1 vote
2 answers
4k views

Copy files based on timestamp in a batch file

I need to copy files based on timestamp. Example: I have folder1 and folder2. Files from folder1 should be copied to folder2 and then once a day all files from folder2 will be uploaded to the ...
susik's user avatar
  • 653
1 vote
4 answers
6k views

BATCH Script - how do I count occurrences of COMMA in a CSV or TXT file?

I have bunch of CSV files to process daily. They have a constant form with 19 COMMAS to appear in every file. In the file, there is a mixture of strings, timestamps, integers and float digits. The ...
Piotruncio's user avatar
1 vote
2 answers
18k views

Delay batch files in between commands

How do I delay batch files in between commands, with say a once second delay, or even less? I've tried using the ping null command, but it never seems too work for me? ping 127.0.0.1 -n 1 > null ...
Xaxis's user avatar
  • 115
1 vote
8 answers
56k views

Executing a powershell script through batch file

I am trying to execute a powershell script through a batch file, at the moment I am only testing this to get it running so the .ps1 file is simply a hello world script. This ALMOST works fine except ...
Csothcott's user avatar
1 vote
2 answers
327 views

Escaping the < sign with ^ does not work in .bat file

I'm trying to write a batch file that can generate some XML config files, but escaping the < and > signs does not seem to work. At the start of my script i wrote a test: SET test=^<foo^>^<...
K.L.'s user avatar
  • 113
1 vote
1 answer
848 views

A .bat file to close two services running in background

I have a Windows 7 computer with three accounts (in hierarchical order): Administrator (with password) type Administrator Guest (with a password different from that of Administrator) type ...
AiaceT's user avatar
  • 45
1 vote
1 answer
2k views

How can I simulate Make's targets within a Windows batch file?

In working towards resolving https://tex.stackexchange.com/a/160685/17423, I'm looking to create a batch-file version of this makefile. Is there a clear/conventional way to simulate the 'target' ...
Sean Allred's user avatar
  • 1,242
1 vote
2 answers
6k views

Batch script to remove # from a file name (only in a specific directory)

I'm looking for a script to remove the # character out of any file names in a specific directory (PDF documents). I've been looking at some similar examples, but it's all a bit confusing!
David's user avatar
  • 11
1 vote
2 answers
12k views

open a command prompt and setting the default path

I want a .bat file which opens a command prompt and then set my default directory also set the enviromenet variable JAVA_HOME For now I am manually openning command prompt and then setting my project ...
Ram Dutt Shukla's user avatar
1 vote
1 answer
4k views

Restarting server with bat file

I'm trying to make a simple bat file that restarts a server. It looks like this: shutdown -r -f -t 60 But all it does is loop inside the cmd window, printing the command > new line > priting the ...
Jason94's user avatar
  • 1,195
1 vote
2 answers
6k views

How do I check if a program's instance is running or not, before running that program?

I am looking for a software (could be as a BAT script) that could check if a program's instance is running or not, before running that program. And if the software / script detects that the program is ...
galacticninja's user avatar
1 vote
2 answers
29k views

How to run bat file in background? [duplicate]

Possible Duplicate: Run a completly hidden batch file I have a bat file that open a window and show a lot of information, which bother me a lot. How could I run the bat file in background?
Jichao's user avatar
  • 7,460
1 vote
1 answer
54 views

Any way to do a Batch file move operation only when the HDD is idle-ish?

I know how to check if a specific program is running like winrar which might indicate usage on drive d: but is there a better way to determine if a drive is relatively idle enough (via Batch or other ...
Bricktop's user avatar
  • 303
1 vote
2 answers
494 views

Batch move files to different subfolders

I've about 600 files that I want to move to different subfolders based on the number at the beginning of the filename. E.g. 5--US-L.jpg -> subfolder /5/5--US-L.jpg 7--US-M.jpg -> subfolder /7/7-...
CS5TK's user avatar
  • 11
1 vote
1 answer
3k views

How to launch an app from a minimised Batch File so that it is in focus?

Consider the following code: timeout /nobreak 10 start notepad.exe timeout /nobreak 5 if I run it in a focused Batch File then Notepad launches as the active window. If however I minimise the Batch ...
TechHorse's user avatar
  • 347
1 vote
2 answers
1k views

Having issues with value of 08 Using SET /a in a windows batch file

I have a bunch of batch files that use set /a to fill out variables for month, day, year, etc. Example: Set/a Year = %date:~10,4% Set/a Month = %date:~4,2% Set/a Day = %date:~7,2% Any time the value ...
Zach's user avatar
  • 1,018
1 vote
2 answers
820 views

How to make cmd read input with spaces as different terms/variables?

When I want my batch to get input, I use: set /p myvar=Type here: By running the code and inputting something like this with spaces: This is the input. Can I get the four words seperately assigned ...
batchcoding____s's user avatar
1 vote
2 answers
54 views

Where would I change the firewall setting in this setup?

Question: Is it possible to make a Windows Firewall application exception via command line or any other way? Why We have a host running Windows 2016 Server with several Hyper-V VM's also running ...
Lzypenguin's user avatar
1 vote
2 answers
12k views

Batch Script: Can We set a String with space in SET /p command?

for example, code; :void.loop set command= set /P command= if %command%=="this is a test" goto :void.loop now, i am writing " this is a test " in the command promp... the output is; "...
Hüseyin Teoman Deniz's user avatar
1 vote
2 answers
2k views

How to negate %errorlevel% of the command in one line?

I've got true and false commands on my CMD (as part of Git Bash) for testing purposes. So here are the basics: C:\>true C:\>echo %errorlevel% 0 C:\>false C:\>echo %errorlevel% 1 The ...
kenorb's user avatar
  • 25.4k
1 vote
1 answer
17k views

Windows Batch File: How to run multiple batch commands?

I'm trying to do some basic functionality using a batch file but the batch file opens cmd and runs the first command but then stops, ignoring the other commands. I've tried using START and CALL but ...
Mr.B's user avatar
  • 113
1 vote
2 answers
2k views

How to Create individual text files from a wmic output

I want to create individual text files from each entry in a wmic output. So far I have WMIC.exe /Node:localhost /Namespace:\\\root\SecurityCenter2 Path AntiVirusProduct Get displayName /Format:csv>...
Flaver-D's user avatar
  • 165
1 vote
2 answers
3k views

Open folder from CMD using wildcard

I'm using FileMaker Pro and would like to be able to open a folder in Windows Explorer given a folder path that isn't 100% complete. We have a Contracts drive where our jobs get saved = X:\ in that ...
Philip McGeehan's user avatar
1 vote
4 answers
10k views

Using a batch file, can I rename files within a ZIP file?

I have a batch file which renames files. Is it possible to rename files within a ZIP file? If not, is it possible to "extract" them in the background, rename them and "add" them back into the same ...
MaKu's user avatar
  • 13
1 vote
2 answers
2k views

%HOMEDRIVE% is not giving the expected output

When i run the below batch script @echo off cd /d D:\Home\Folder echo %HOMEDRIVE% pause I get H: as the output. But ideally it should be D:. Why is it so?
Mathew's user avatar
  • 117
1 vote
2 answers
17k views

I need a batch file that opens cmd, runs two commands, and keeps cmd open

I am making a set of batch files made to force restart games when they freeze and won't start back up again. So I need a batch file that opens cmd.exe, runs the two commands: taskkill /F example....
jakob qasadilla's user avatar
1 vote
2 answers
2k views

Quickly create a new Firefox profile and load Firefox with it

I want to be able to quickly create (and delete) Firefox profiles for testing purposes in Win 7 SP1. To do this, I created a batch file with the single line: firefox.exe -CreateProfile test &&...
End Anti-Semitic Hate's user avatar
1 vote
2 answers
3k views

Is it possible to execute batch commands from Windows shortcuts?

I'm trying to run some programs from a flash drive. Therefore, I want them to keep their data on the drive as well. I know how to do this using the following batch script; APPDATA=%CD% Program.exe ...
Jaïr Paalman's user avatar
1 vote
1 answer
973 views

MS-DOS copy command

Hello this is something that has been on my mind for quite some time. How can you copy just say the first 5 files out of ten with one command. For example: file1.txt file2.txt file3.txt file4.txt ...
atom715's user avatar
  • 111
1 vote
3 answers
1k views

How do I set a variable (by prompt) in MSDOS 7.1

In CMD, I could do Set /P ASK=REPEAT and it would prompt the user for ASK. How do I do this in MSDOS Batch Files? (No, no the ones that run on NT, but the ones that run on MSDOS.) Btw: 'Set /P' is an ...
Roke's user avatar
  • 1,032
1 vote
2 answers
318 views

Batch File Pause

I was testing out a batch file and I put in pauses to double check that the script was functioning properly. My question is, if the script encounters a pause, and I alter the script, either add a ...
user avatar
1 vote
1 answer
71 views

How to have a batch call another batch based on its location?

I have made a file I will put up for download. It involves one batch file calling another. Most of the time this is not a problem, but in my case I have no clue where they will download it. So how ...
Gizmobart's user avatar
1 vote
2 answers
9k views

Move 1 file at a time based off timestamp using windows batch utility

I am trying to build a .bat file to move files from 1 folder into another one, based off of the oldest time-stamped file. Folder 1: Filename: Date Modified: test1.dat 5/12/2014 4:03pm ...
Brian's user avatar
  • 11
1 vote
2 answers
18k views

How to schedule taskkill in bat file

I want something like this:- taskkill 7z.exe after 50sec. code 1 code 2 code 3 7z.exe will be killed after 50 sec but the program should execute code 1 code 2 code 3 without waiting for the ...
Deb's user avatar
  • 219
1 vote
2 answers
4k views

Filling up the hard drive until certain amount of space is left?

I'm doing some testing of a product on Apple and Android devices. I'd like a script that will fill up the devices hard drive until 100KB space is left on the drive it's runs against to. Also in linux ...
Rubynator's user avatar
1 vote
1 answer
7k views

windows script to copy text from one file into a new file

I am noob at coding! I am trying to create a windows script that I can copy text from one file into another. My main goal is to find lines in the text with "started processing" and "file". I am hoping ...
Sam's user avatar
  • 11
1 vote
4 answers
10k views

Minimize a program's windows after running it via .bat/.cmd

I'm trying to find a way to auto-minimize a program just after running it from a .bat file. I'm launching a SSH session via putty, and I'd like putty to auto-minimize. I use it just for the SSH tunnel....
Robinson G.'s user avatar
1 vote
1 answer
5k views

Edit files from a batch script

How would I edit a file from a .bat file that changes the contents of a file located somewhere on the hard drive. For example there is a file on my desktop, can I make a .bat script that will add a ...
Megaeverything's user avatar
1 vote
2 answers
515 views

CD command not returning correct results under FOR loop

The CD command returns the current directory, and the %CD% variable returns the same result in an environment variable: c:\Temp\test\test1>cd c:\Temp\test\test1 c:\Temp\test\test1>@echo %cd% c:...
Preet Sangha's user avatar
  • 1,143
1 vote
1 answer
6k views

How to get Windows language programmatically? [closed]

I need to install some version of one package depending on the SO language. How can I get it using a batch file? I'm using W7 professional.
AbrahamSustaita's user avatar
1 vote
3 answers
2k views

Dump HTML from script

Is there a way to create a script to download the HTML source to a text for html file locally? For example, if I wanted to archive the HTML of Google.com each day. I'm up for batch, VBS or PS1 but ...
Jeff F.'s user avatar
  • 4,413
1 vote
1 answer
1k views

using "at" command in command line to create repeatable tasks

I got an answer about this question, about 2 years ago, but now I want to use the same command to create a task that will run every half an hour. How can that be done? Thank you in advance.
bks's user avatar
  • 231
1 vote
3 answers
628 views

bat file for backup system

I created a sample bat file in order to have a back-up system. this does not show what my intention is but it demonstrates it. here is my bat file content; xcopy C:\apps\source c:\apps\dest /D /E /C /...
tugberk's user avatar
  • 411
1 vote
1 answer
65 views

Batch file to output MD5 hash to a text file starting at a specific directory

@echo off set "src_dir=C:\Users\\Documents\projects\Config\ABC" set OUTFILE="C:\Users\Documents\Scriptoutput.txt" echo %OUTFILE% pushd %cd% cd %src_dir% for /r %%f in (*) do ( ...
Sam sh's user avatar
  • 21
1 vote
2 answers
1k views

How to sort the files which are returned by findStr command, by modify date?

Currently, I need to find out all the files which contains the key word. Here is the command I am using findstr /s /i "my-key-word" *.*. How can I sort the returned files by its modify date? ...
Robin Sun's user avatar
  • 121
1 vote
2 answers
579 views

Batch processing stdin lines with Windows batch .bat script

I have a Windows batch script delete.bat with that contents: @echo off takeown.exe /A /R /F %1 icacls %1 /grant Administrators:(OI)(CI)F /C /T /Q /L rmdir /S /Q %1 echo %cd%\%1 >> "C:\...
Chameleon's user avatar
  • 207
1 vote
1 answer
524 views

Can "__compat layer" halt viruses?

In Windows we can use set set __COMPAT LAYER=RunAsInvoker to stop applications from getting administrative privileges. So if I use this on a virus executable then will it stop the virus from affecting ...
jastyles's user avatar
1 vote
2 answers
2k views

How to detect that a Windows application is running (no GUI)

Would like to have a suggestion on how to detect (preferably in such a way a batch file could use the result) whether a certain application is running so that some action could be taken. (Of course, ...
pstrg's user avatar
  • 23
1 vote
3 answers
5k views

Get hard drive serial number based on drive letter on Windows Command Line (not Powershell) and store in variable

I know I can get the serial number of all listed hard drives by using: wmic diskdrive list brief or specifically wmic diskdrive get serialnumber And I can get the drive letter from the logical disk: ...
HTWingNut's user avatar
  • 499

1
18 19
20
21 22
62