Questions tagged [batch-file]

batch files are simple text files executed in a command to achieve a particular task or a set of tasks

batch files are text files containing commands executed in sequence to achieve a particular task or a set of tasks. They can be very simple, or can contain complex logic.

440 questions
7
votes
6 answers

Delete temporary files from batch script in xp

I'm looking for a good batch script that would quickly find & clean all the known safe temporary folders/files from Windows (as many variants as possible) machines (e.g. the windows temp folder, all users IE temp folders, etc.). I'm fond of UI tools…
Keith Bentrup
  • 719
  • 3
  • 8
  • 19
7
votes
2 answers

How to make Batch-file automatically stop on error

Do anyone knows if there is a Windows Batch-file equivalent to Unix Stop on Error "#!/bin/sh -e"? (http://www.turnkeylinux.org/blog/shell-error-handling)
jpmartins
  • 1,404
  • 2
  • 12
  • 14
7
votes
3 answers

Scheduled Tasks w/ GUI issue

Are there issues running Scheduled Tasks in Windows 2003 when the task has a GUI? I have one that worked fine in Windows 2000 but won't run on Windows 2003. Details: I have a .bat job that ran every hour throughout the day on an old Windows 2000…
Chris_K
  • 3,444
  • 6
  • 43
  • 45
6
votes
6 answers

Correct technique to find application in 32 and 64 bit versions of Vista/Windows 7 from CMD.EXE

BACKGROUND I have an existing CMD script that works fine. It launches an app from PROGRAM FILES like so "%PROGRAMFILES%\MyApp\app.exe" PROBLEM it works fine on 32-bit versions of Windows (Vista, Windows 7) but on 64-bit versions of Windows the…
user2666
  • 285
  • 2
  • 6
  • 8
6
votes
1 answer

How do I script a change to the msmq storage location on Windows 2008 R2 server

Is there any way of doing this through a batch or powershell script? I'm looking for a way to set up several new servers. The only thing I found on the subject leads me to believe you cannot: from…
Hugo Forte
  • 161
  • 5
6
votes
3 answers

Backup with Mercurial and Robocopy?

The Problem We would like to backup our critical files from several network shares to a removable hard drive. We want to automate the backup so we don't have to remember to run it. It needs to finish overnight. Furthermore, we want to be able to…
Andrew Neely
  • 189
  • 11
6
votes
2 answers

Mass delete mapped & local printers

Is there any way to mass remove all local and network mapped printers from all workstations on a domain via group policy or a batch file? I need to remove local Windows 7 printers such as Fax, Microsoft XPS Document Writer, Send To OneNote 2010.
Ash
  • 485
  • 9
  • 18
  • 28
6
votes
2 answers

How do I get the last part of directory from a command line

How do I store the last part of directory in a variable? For example I have the following path: A\B\C\D, I want to store D in variable like file_name=D.
Mohammad AL-Rawabdeh
  • 1,612
  • 12
  • 33
  • 54
6
votes
3 answers

Line break in batch file

I have a simple batch file (forbat.bat), with the following content: FOR /F "tokens=4 delims=," %%G IN ("deposit,$4500,123.4,12-AUG-09") DO @echo Date paid %%G When I run this batch file, I can get the result. Now, I want to break the lines into a…
Graviton
  • 2,865
  • 12
  • 42
  • 64
5
votes
4 answers

Windows 2003 batch file Sleep/Wait function

Possible Duplicate: How to sleep in a batch file? I have a batch file that runs as a secheduled task in windows server 2003. This batch file purely calls around 20 other batchfiles one after the other. When this runs it causes quite a spike on…
Robin Day
  • 506
  • 1
  • 8
  • 19
5
votes
2 answers

How to query the task manager

I know the tasklist command in Windows will give a list of task names and their PID. There is another command WMIC path win32_process get Commandline which does give more detailed information, but its output is much messier and sometimes…
E.S.
  • 155
  • 1
  • 6
5
votes
2 answers

Batch script is not getting executed when called by Start-Process Cmdlet

I have a strange issue on a Windows Server 2012 R2 here that just does not make any sense to me at all. I've got a PowerShell script that basically has the following structure: Function Something-Different { [...] } Function…
Matthias Güntert
  • 2,438
  • 12
  • 39
  • 59
5
votes
1 answer

Including a bat file in a bat file

I have many bat files that share a common setup of variables. Instead of defining the same variables over and over again (and making errors in the process) I would like to include one bat file in all the others. How do I do this? Excuse my newbie…
raoulsson
  • 4,763
  • 10
  • 34
  • 29
5
votes
1 answer

Windows Task Scheduler cannot access EFS encrypted folder despite running as a user with access

I have a batch file set to run via Task Scheduler in Windows Server 2008 R2. The batch file is being used to rotate and compress MySQL logs, and the folder containing these logs is encrypted using the Windows built in EFS encryption. I found a VBS…
5
votes
2 answers

How to pipe program output to the screen AND to a file under Windows

I have a command which I need to inspect in real time (i.e. see its output in the command prompt MyProgram.exe) and to have a log file for later inspection (MyProgram.exe > log.txt) How can I make a single instance of the program to write to both…
Dani
  • 1,226
  • 1
  • 13
  • 20
1 2
3
29 30