batch

how to pass clipboard to batch in xp

using windows xp i want to copy text (url) to the clipboard then run a batch file that will use that url. i know the reverse is possible with the clip.exe floating around. ...

How do I retrieve the version of a file from a batch file on Windows Vista?

Binary files have a version embedded in them - easy to display in Windows Explorer. How can I retrieve that file version, from a batch file? ...

How to split a string in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n] EDIT Thanks for the helpful answers. In the end I decided that this was trying to make a batchfile perform unnatural acts, so I went with...

Find and Add line in text file from batch

I would like to know if anyone can help me with this. I would like to search a text file for a certain line of text, add a new line under the specific line then add text to the new line. I will be using this to edit the firefox.js file to add the line of text to add support for Iprism. It will run on XP and Windows 7 machines. I would l...

Batch Size in web config for Nhibernate in ASP.NET MVC

How do I set the batch size for Nhibernate? I'd like to do this in the web.config. The examples I see, don't make a lot of sense to me. In this example they are using code to set the batch size. I don't wnat to do that. I want it configurable in the web.config. I understand how to add the config section, I just have read articles t...

Output results of a task in a FOR loop with added variables for logging

G'day all, Trying to output the results of the task I'm running in a FOR loop with additional data. In this case, I'm using the FOR loop to read in server names from a text file to setup a scheduled job. I would like to capture the results on each loop and output to a log file but need to insert additional information such as server nam...

32bit application access to 64bit registry

I have an OS Shell written in 32bit that is replacing the Explorer.exe of a Vista machine. I run a utility which is also written in 32bit, which allows to switch between the Explorer shell and My shell. With some of the machines being 64bit based I can not Alter the HKLM\Microsoft\current\shell Key (short formed reg key). I end up gettin...

Asterisk (*) in windows batch file command line argument gets expanded

Hello, I have a batch script that takes arguments from the command line. One of the arguments has a * in it. In spite of putting the argument in quotes, the * gets expanded before the argument gets used in the batch script. I am using the following code to parse the arguments: set CMDLINE_ARGS=%~1 shift :get_args if "%~1" == "" goto ...

Why is this variable appearing as undefined?

I have this code: FOR %%d IN (c d e f g h i j k l m n o p q r s t u v w x y z) do ( IF NOT EXIST %%d:\ ( echo Free drive %%d set D=%%d: ) ) echo d=%D% echo Using %D% to map remote drive subst %D% /d subst %D% \\path_to_drive and after this I'm using the D variable to map a free drive. The thing is, when I first ...

Is it possible to put a new line character in an echo line in a batch file?

Is it possible to put a new line character in an echo line in a batch file? Basically I want to be able to do the equivalent of: echo Hello\nWorld You can do this easily enough in linux but I can't work out how to do it in windows. ...

How do I get each comp result ?

I would like to check diffs and when files are not same,stop compare files. Compare any files C:/UML/reports/* and C:/UML/Test/*. In this two directory has same file names and also aim is to want to compare same file by name. I try to that by below code in .bat file. diff.bat @echo off for %%i in (C:\UML\reports\*) do comp %%i C:\UML...

Why %processor_architecture% always returns x86 instead of AMD64

I am trying to retrieve the environment variable to detect whether the system is 32 or 64 bit. But on 64 bit server the environment variable %processor_architecture% is returning x86 instead of AMD64. Does anyone has any clue about this? ...

complex batch replacement linux

I'm trying to do some batch replacement for/with a fairly complex pattern So far I find the pattern as: find '(' -name '*.php' -o -name '*.html' ')' -exec grep -i -n 'hello' {} + The string I want to replace is currently as follow: <img src="/some/path/to/somewhere/hello" /> where the path for the image varies but always contain t...

Batch Script issue

Hello, for deleting files, I will be using the code below to remove the oldest file in the directory and run it every day. It came from the question of mine. Applying to the original batch script: SET BACKUPDIR=C:\PATH\TO\BACKUPS FOR /F %%i IN ('DIR /B /O-D %BACKUPDIR%') DO SET OLDEST=%%i DEL %BACKUPDIR%\%OLDEST% Something such as th...

Batch delayed expansion not working.

Ok, I'm getting crazy and I don't know what else to do, I've tried several things and nothing is working. Look at this sample code (test.cmd): setlocal enabledelayedexpansion enableextensions set VAR=before if "%VAR%" == "before" ( set VAR=after; if "%VAR%" == "after" @echo If you see this, it worked ) This is the generated o...

Translating a Windows batch file into a Linux shell script

I have a batch file that I use to check whether my sites react to a ping. If a site doesn't react, the script writes the output into a text file. I wanted to use the same kind of script on a Linux system. Can anyone help me translating the code so that I can use it on a Linux shell? set list=domains.txt If "%list%" =="" GoTo EXIT for ...

Resources To Learn About Batch Files

In my new project I need to use batch files(many of them), but now I need to know about they and where can I read some good tutorials to use they very good ;) PS: I need to distribute my application for end-users. ...

Change IIS 5 virtual directory in Post-Build Event in Visual Studio

I'm running into an issue where I need to be able to change the target directory path that my IIS 5.0 virtual directory is pointing to from within a Post-Build block in Visual Studio 2008. If you're not familiar with Post-Build events they basically just take batch commands. So if you know of a batch command for IIS 5.0 in XP Pro that c...

How can I make my batch script for deletion of old files work?

Inside a folder (say c:\test) I want to delete the oldest file if the number of files are over 21. This is what I came up with, issue is that it one time deletes the oldest file, second run it does nothing and deletes the oldest for third, continues like that. Also it doesn't care if the file amount is lower than 21, deletes even if it ...

while loop in batch

Hello Here is what I want, inside the BACKUPDIR, I want to execute cscript /nologo c:\deletefile.vbs %BACKUPDIR% until number of files inside the folder is greater than 21(countfiles holds it). Here is my code: @echo off SET BACKUPDIR=C:\test for /f %%x in ('dir %BACKUPDIR% /b ^| find /v /c "::"') do set countfiles=%%x for %countfiles%...