batch-file

Run batch file as a Windows service

In order to run one application, a batch file has to be kicked off (which does things like start Jetty, display live logs, etc). The application will work only if this batch file is running. I am hence forced to have this batch file running and not logout from the Windows server. Can this batch file be run as a service? I am experimenti...

Change a shortcut's target from command prompt

I'm normally a Linux guy, but I need to write a batch script on Windows to change the target of some shortcuts. Is there a command to do that? ...

How do I hotcopy a SVN Repository to an existing location?

I am trying to automatically backup my SVN Repository. This is in a batch file I wrote: svnadmin hotcopy C:/myRepository G:/myRepositoryBackup --clean-logs It works great the first time. However, each time after that, I get this error: svnadmin: 'G:/myRepositoryBackup' exists and is non-empty How do I have it overwrite my old dat...

How to call Nunit from Visual Studio in a batch file

I have set my Visual Studio to start Nunit as an external program to run all the tests written in a module. Now what I am trying to do is to create a batch file which will call Myproj.exe. What I am expecting is that it will run Nunit as I have set it to run an external program and execute all my tests in nunit.exe, but when I run that...

How can I sync the computer's clock upon startup?

I have several servers hosted with GoGrid, and every time I reboot one of my cloud servers, the system clock is incorrect. The server isn't a member of a domain, so I just have the OS set to sync with an Internet time server. This only happens once a day, and I don't see an option to make this happen automatically upon reboot. So I'm lef...

Need help with a .bat script for parsing W3C logs

Im trying to get a value (IP address) from a W3C logfile (kinda like a text file). This is what I have so far but with no luck: Set filename=ex%date:~-2,4%%date:~-10,2%%date:~-7,2%.log For /F "tokens=2 delims=: . " %%A in ('E:\WINDOWS\system32\LogFiles\MSFTPSVC6141885\%filename%') do (Set ip=%%A) and the log file looks like: # So...

Calling batch files with make and making changes persistent

Hi, I'm programming with Visual C++ Express on the command line using makefiles (GNU Make). For this to work, I have to call the Visual Studio batch file vsvars32.bat to set up the environment. This has to be done everytime I open a new cmd.exe, before using make. When I try to call the batch file from my makefile, it obviously executes...

batch not working if calling from a Java program

I wrote a batch file that reads in a text file which contains a list of file name, and then delete and rename them one by one. I did this by using a for loop, and it works perfectly by double clicking it. But when I tried to call this batch from a Java program. It's no longer working for this part: for /f %%a in (ListFile.txt) do ( ...

How to copy a directory structure but only include certain files (using windows batch files)

As the title says, how can I recursively copy a directory structure but only include some files. E.g given the following directory structure: folder1 folder2 folder3 data.zip info.txt abc.xyz folder4 folder5 data.zip somefile.exe someotherfile.dll The files data.zip and info.txt can ap...

Is PowerShell a good upgrade for a batch file?

I package our server releases into zip files using a batch file (Windows), running the command-line version of WinZip. Previously we did this sort of thing "by hand" but I developed the process of automating it with a batch file. The batch file has become quite complicated because our product is complicated (i.e., Which sections are we ...

Create bat or script file to delete files

I would like to know how to create a bat file which on its first run would store the system date and on subsequent run delete a particular file 30 days later.I think if a bat file can be created that would store system date on its first run and the second bat files reads the first file for the date would be better.But how? ...

How do I echo and send console output to a file in a bat script?

I have a batch script that executes a task and sends the output to a text file. Is there a way to have the output show on the console window as well? For Example: c:\Windows>dir > windows-dir.txt Is there a way to have the output of dir display in the console window as well as put it into the text file? Thanks ...

How to Tell FORFILES to Execute Command on Path?

I'm missing something (obvious?) about escaping my strings or spaces in the following Windows Server 2k3 batch command. FORFILES -m *.wsp -c "CMD /C C:\Program^ Files\Common^ Files\Microsoft^ Shared\web^ server^ extensions\12\bin\stsadm.exe^ -o^ addsolution^ -filename^ @FILE" Results in the following error 'C:\Program Files\Common...

DOS Script to take file name and path dyanmically based on date

I have to write some batch/dos script in windows which will put the files in UNIX box. But the path and filenames are getting changed every year and month respectively in windows. Suppose a directory in windows at path C:/2009MICS which will hold the files for whole year( 12 files). My batch will run monthly and should pick the files fo...

How can I simulate a disk full error in a Windows environment?

I have to write a bat script for a test scenario where the software that we are testing fails to write to file due to a disk full error. The test script must be automated, so that we can run it on overnight tests, for example. The test script must also work at different computers, so installing a software like a virtual machine wouldn't ...

a problem with batch file

Dear all i created a batch file which uninstall my application .. my problem is this uninstallation deleted some files and keeps others for example i created a folder in C:\Documents and settings\User-Name\myCompanyName\My Application name\ this folder contains all files for my application now when i uninstall all these files are deleted...

how to pass parameters from html page to batch file

Hi, I have the following requirement. I need to pass parameters from html page to batch file which in turn passes the paramter to xml file.I need to know how to pass parameters from html to batch file and from batch file to xml file Thanks ...

Deleting empty (zero-byte) files

What's the easiest/best way to find and remove empty (zero-byte) files using only tools native to Mac OS X? ...

How to achieve per-batch-file echo on/off setting?

We have some complex bat files where one calls another, which calls yet another. All of them have a @echo off at the top. For debugging, I would like to selectively turn echo on in some of them. What is the easiest way to do this? Some ideas I have so far: Change the setting only in top level files. But this will only work for the few...

Creating folder using bat file

I need to write a bat file which creates a new folder using current date and time for folder name. I came up with the following: for /f "tokens=1-3 delims=:," %%i in ("%TIME%") do md %DATE%-%%i.%%j.%%k Does this code has any flaws? Is there an easier / more natural way to do it? ...