batch

Windows: How to display a non-blocking Alert/Confirmation window?

I want to realize a simple confirmation/alert box which can be called using a Windows XP/Vista batch script by CLI. The standard alert box seems to be blocking which means that the whole batch script will stop at the time of the alert window call which is NOT what I want. If it needs to be coded, please supply an example or documentati...

How can I copy files to the "newest subdir" in a directory using a batch file?

I need to copy files from recent build folder to another folder used for testing. I'm having a hard time getting the name of the most recent build folder. My current attempt is this: @for /D %%i in ('dir e:\builds\projectA\* /O:D') do set target=%%i echo %target% xcopy "%target%\*.*" \\devbox\projectA /y /s I was hoping target would...

Windows batch script to print error message if port in use

I'm trying to write a batch script that errors if port 1099 is already in use. Unfortunately I have to write it in a DOS batch script (I cannot install anything). I know that I can print the PID of the process hogging port 1099 manually: netstat -aon | findstr ":1099" But I want to be able to run that command in a batch script and e...

concatenate variables

Hi, I need to do a .bat for DOS that do the following: set ROOT = c:\programas\ set SRC_ROOT = (I want to put the ROOT Here)System\Source so after defining ROOT I want to have SCR_ROOT = c:\programas\System\Source How can I do that? thanks ...

get path from txt file

Imagine I have a txt file with a path like: c:\programs\SRC_CODE\ How can I do a .bat file that open the txt file and get the string in order to set a variable witht the path catched from the txt? thanks ...

issue commands to window/process started from batch file

Hello Internets :) I want to pass commands to a process started in a batch file, specifically Cygwin. For instance, if I start Cygwin with something like the following: start "window1" cmd.exe /c cygwin How might I execute 'ls' in "window1", in the same batch file from which I started Cygwin? ...

Seach for a word inside .txt file using batch file

I am looking for a batch file to search through a txt file and if it finds the word "Failed" then EXIT 1. Any help?? ...

New window question for batch (.bat) files.

I'm using a batch file to open a few new windows. Once they complete their processes, I have the /c set they quit. However, I'd like for my main batch process to wait for one window to finish before moving on, instead of doing everything at once. For example, if my main batch file has: @ECHO OFF start "Win1" cmd.exe /c scomp -out ........

In a batch file, how do I delete all files NOT of a certain type...

I'm writing a batch file that needs to delete all the files in a certain dir and all of it's subdirectories except those of a specific type. How can I do this? ...

Most efficient and reliable way to get Unix files into SQL Server

I've got three files on AIX that I need to import into a SQL Server 2005 database. The files are created by an AIX script that I have control over. There are several options that I know will work, but I'd like to find out what others have done before and what works best. Here are the options I'm looking at. Have the AIX script sftp th...

How do I test the current drive letter in a batch file?

I'm trying to write a batch file that takes the drive letter the batch file is being run from, and uses it an an IF statement. If the letter is M: for example, it will jump to the label :mSection. Is this even possible? Thanks ...

Access denied when trying to copy file Windows Vista

I have this batch that needs to run that the user has to execute that will copy a simple xml file. However, everything works fine on windows 2000/XP. However, on windows Vista I get an error 'Access Denied". Even when I try and copy the file just using windows explorer on Vista I get the same error. Is there anything I can do to make...

Parse quoted text from within batch file

I would like to do some simple parsing within a batch file. Given the input line: Foo: Lorem Ipsum 'The quick brown fox' Bar I want to extract the quoted part (without quotes): The quick brown fox Using only the standard command-line tools available on Windows XP. (I had a look at find and findstr but they don't seem quite flexib...

In detail: mklink and its options.

I recently followed a small tutorial on howto install apache on a systems where you're not the admin. Basically, the original htdocs and conf folders were copied to a map I have ownership over, the original ones deleted and then symbolic links were created. Now, I checked mklink /? and it gives several options. Directory symbolic link...

Batch file fails to set environment variable within conditional statement

Why does the following Windows Batch File output Foo followedby Bar, rather than Baz? @echo off setlocal set _=Foo echo %_% set _=Bar if 1==1 ( set _=Baz echo %_% ) The output on my system (Microsoft Windows XP [Version 5.1.2600]) is: Foo Bar If I remove the conditional statement, the expected output of Foo and Baz is obse...

windows batch programming: how to get the error level of commands in a pipe

Batch files return the error code of the last command by default. Is it somehow possible to return the error code of a former command. Most notably is it possible to return the error code of a command in a pipe? For example, this one-line batch script foo.exe returns the error code of foo. But this one: foo.exe | tee output.txt a...

Programatically install Certificate Revocation List (CRL)

I need to download and install about 50 CRLs once a week and install them on several Windows servers. Downloading is the easy part, is there a way I could script the CRL import process? ...

Strange/simple batch question regarding Java/Ant

For my company, I'm making a batch script to go through and compile the latest revisions of code for our current project. I'm using Ant to build the class files, but encountered a strange error. One of the source files imports .* from a directory, where there are no files (only folders), and in fact, the folders needed are imported right...

Honoring exit codes from batch files invoked by msbuild

I have a batch file that is using the exit command to return an exit code. This batch file may, in some cases, be invoked interactively from a commandline, or in other cases, may be run as part of an MSBuild project, using the Exec task. If I use exit %errorlevel% within my batch file this works well and MSBuild sees the error code, h...

Batch programming, stop and start services

It is save to terminate the services using taskkill when the attempt to stop using NET STOP was failed? And if i terminate it using taskkill, do NET START command will affect or do i need to use START command? consider this code as example: @ECHO OFF :STOP NET STOP someservices IF ERRORLEVEL == 0 GOTO :START GOTO :KILL :START NET STA...