batch-file

How do I get a for loop to work with a comma delimited string?

This is my code so far: for /f "tokens=1 eol=," %%f IN ("1,2,3,4") do ( echo . echo %%f ) I'm expecting that to produce: . 1 . 2 . etc... But instead I get: . 1 And that's it. What am I missing? ...

Temporarily set file associations.

I have a portable development tool that I want to use on other PCs. I'd like to set a file association so that clicking a file opens the tool. Then, when I'm finished, I want to undo or reset the file association on that PC. Is there a way to do this? Possibly from a batch file? ...

Newbie Question about batch files/table read ins

I am trying to write a little script that will help my office automate the uploading of zips and self extractors to a ftp site. They have to create several zips/se's and name them various different things etc. My idea is for them to have a little table they could type in (i.e. the name they want the file to be called, the location of...

Problem with Batch File

I have the following Batch file... When I run it in a normal command prompt - it runs as expected... Find that the server and destination exist, and does the backup and exits. When I run this using the task scheduler - it sends the email that it cannot find the server, but still does the backup... Can anyone shed some light on this? I'...

How to print a value from a file with comments printed?

In a program am getting one input say name.... From a file i read value line by line: say file contains... hello hai If i want to print like hello name in batch file hai name in batch file How to do this? ...

Logical operators ("and", "or") in DOS batch

How would you implement logical operators in DOS Batch files? ...

Read the first line of batch file from the same batch file?

I have a batch file that tries to run the program specified in its first line. Similar to Unix's shebang: C:\> more foo.bat #!C:\Python27\python.exe %PYTHON% foo-script.py C:\> What I want to know is: is there a way to automatically set %PYTHON% to C:\Python27\python.exe which is specified in the first line of the script following the...

Execute with parameters

I'm having difficulty executing a batch file in Java that expects parameters. These parameters may contain spaces so I need to wrap them in quotes. I will also need to do the same thing for Linux because some of the parameters may contain special characters such as !. Non-functional Windows code: ProcessBuilder pb = new ProcessBuilder(...

Vb.net - Select listbox item based on string

Hi, I'm trying to write a small app which can be used in order to log off Citrix Sessions. Citrix Sessions can be logged off via cmd or a batch file using this method: @echo off echo "Enter username" set /p UserName= echo 001 query user %username% /server:server1 echo 002 query user %username% /server:server2 echo 003 query user %user...

how do I get a for loop to work on a single line comma delimited string with spaces

I've got an input to a batch file that contains a list of files (this is all one line and one of many inputs to the bat file): "\\Server\my directory name\subdir,\\Server\my directory name\subdir2,\\Server\my directory name\subdir3" I'd like to iterate this list and perform a command on each directory in the list. However, when I spec...

Output of sub-processes in DOS batch script not visible in Apache

Hi, I'm running Apache 2.2 (launched via console) on Vista. I have simple batch script in cgi-bin. Unfortunately, Apache does not seem to serve any content generated by sub-processes. For example, given the following script: @echo off echo Content-Type: text/html echo. echo Visible in browser cmd /c echo Hidden from browser echo End o...

Batch script is not executed if chcp was called

Hello! I'm trying to delete some files with unicode characters in them with batch script (it's a requirement). So I run cmd and execute: > chcp 65001 Effectively setting codepage to UTF-8. And it works: D:\temp\1>dir Volume in drive D has no label. Volume Serial Number is 8C33-61BF Directory of D:\temp\1 02.02.2010 09:31 <D...

Getting Short-Filename of Command-Line Argument from Batch-File

Hi, The following command in a batch file does not work as expected/hoped:     echo %~nxs1 Here is a sample display of what I’m trying to get: C:\>type test.bat @dir /b %1 @echo %~nxs1 C:\>test "C:\Documents and Settings\All Users\ntuser.dat" ntuser.dat NTUSER.DAT C:\>test "C:\Documents and Settings\All Users\ntuser.data" ntuser.d...

How do I know the default batch file directory?

Hi Everyone, I'm creating a batch file for SharePoint deployment. The batch will do solutions installation and configuration, create a web application and restore the .dat file on the created web application. Instead of hard code the solutions path and .dat I want batch to know it is on the root. So, if I move this folder somewhere els...

batch file to copy files to another location?

is it possible to create a batch file to copy a folder to another location everytime I login, or when the folder is updated? It could be written in vb or java aswel if not an easy solution. Any ideas? Thanks ...

how to use goto in batch script

Hi All, I have written following code setlocal set /A sample =1 :first type C:\test.txt | find "inserted" if %ERRORLEVEL% EQU 0 goto test if %ERRORLEVEL% EQU 1 goto exam :test echo "testloop" >> C:\testloop.txt set /A sample = %sample% + 1 if %sample% LEQ 4 goto first :exam echo "exam loop" >> C:\examloop.txt endlocal b...

extract few characters from a file by using batch script

Hi All, I want a batch script which will extract the first 30 characters from a file. Requirement: there is one file called test.txt and it's content is \765514e2aad02ca658cc56cdb7884947 *E:\test1 now I need a script which extract only \765514e2aad02ca658cc56cdb7884947 from the above file Thx in advance ...

Changing font color in WordPad

Hi All, Is it possible to change the font color of text while redirecting it to WordPad? Examples: C:\echo greencolor >> C:\colors.rtf -----> This text should appear green in WordPad C:\echo redcolor >> C:\colors.rtf -----> This text should appear red in WordPad C:\echo browncolor >> C:\colors.rtf -----> This text should appear brow...

how to fetch exact string from a text file

Hi All, here is me requirement. I have one text file and I need to get exact specified string from that file C:>type small.txt | find "small2" small2 small22 small20 C:>type small.txt small2 small22 small20 C:>type small.txt | find "small2" small2 small22 small20 C:\ Here it is giving all the words instead of only "small2"...

Writing a batch file for date-based file copying

I need to make a batch file that can copy files from one path to another based on parameters. For example, typing "datecopy -m 8 c:/copyfrom/*.* d:/copyto/*.*", would find all files in c:/copyfrom dated less than 8 months old, and copy them to d:/copyto -folder. Alternately, instead of -m for month, I could use -h for hour or -y for yea...