bat

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...

How do I make a bitwise and in a bat-file?

I have tried with the following, but it just says "& was unexpected at this time." @echo off :enter-input echo Please enter a number between 1 and 15: echo 1 = Selection one echo 2 = Selection two echo 4 = Selection three echo 8 = Selection four echo x = Quit set INPUT= set /P INPUT=Type number: %=% if "%INPUT%" == "" goto enter-input...

Pass path with spaces as parameter to bat file

I have a simple bat script that copies files from an known directory to a directory given by the user. How can I pass the path (it might contain spaces) to my script and use it with the xcopy command? ...

ASP.NET - running a bat script on another machine.

I would like to run a bat script on one of the machines on the domain, from my asp.net application. Machine with the batch script is a temporary storage machine, and script synchronizes it with the permanent storage machine. So, what is the optimal way of doing this? The thing I tried is to use PsExec to run a script on the remote machi...

BAT file to create Java CLASSPATH

I want to distribute a command-line application written in Java on Windows. My application is distributed as a zip file, which has a lib directory entry which has the .jar files needed for invoking my main class. Currently, for Unix environments, I have a shell script which invokes the java command with a CLASSPATH created by appending...

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 ...

Maven package .bat script: how to add a delay?

I have this .bat script which I use to maven package my application. Problem is, just after it ends execution, it closes the console window. The last 2 lines somehow are completely ignored. Does anyone know the trick to make this work? I just want to have a quick check if the build was successful. @echo off cls cd C:\svn\project mvn pa...

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...

Move lines from one .txt file to another

I am trying to move certain lines from one .txt file to another. These lines all follow a certain pattern. I have been looking at using the find command in a batch file, but this does not delete the line from the original file. For example: find \i pattern "d:\example1.txt" >> "d:\example2.txt" Is there any way to achieve this? Th...

Order in which Command Prompt executes files with the same name (a.bat vs a.cmd vs a.exe)

What is the order in which the Windows command prompt executes files with the same name but different extensions? For example I have a bunch of executable files (something.cmd, something.bat, something.exe), which of these would be executed when I typed "something" into a command prompt (given they were on the path etc). If that file di...

how to get the output in column wise in a below batch file

how to get the output in column wise in a below batch file @echo off setlocal enableextensions enabledelayedexpansion set Counter=0 for /f "usebackq tokens=2,5,6 delims= " %%a in (`findstr /c:"Cod " 1231.txt`) do ( set x=%%b set x=!x:~3! set y=%%c if %%c LSS 10 set y=!y:~1! set item!Counter!=%%a-!x!#!y! set /a ...

write a batch file to remove the folders by date and time wise

Exact Duplicates: How to write a batch file to delete the files which are 5 days or older from a folder? write a batch file to delete 6 days older files from a folder write a batch file to delete 5 daya older files from a folder How do I write a batch file to delete folders and files on a time basis? How do I create a batch script that...

How do I write a batch file to delete folders and files on a time basis?

Exact Duplicates: How to write a batch file to delete the files which are 5 days or older from a folder? write a batch file to delete 6 days older files from a folder write a batch file to delete 5 daya older files from a folder How do I create a batch script that will delete a folder on a scheduled basis? write a batch file to remove ...

Favourite command line trick

bash, bat, whatever... What is your favourite command line hyperproductivity trick? ...

"start" does not work in bat file when used as filetype handler in Firefox

I have a batch (bat / cmd) file which should act as a filetype handler for jpeg files in Firefox, I just want it to copy the file to another folder, and then open the file in the Picasa Viewer. When I run it from the command line, even if I'm running it from another folder, it works fine, and opens Picasa Viewer. However, when setting it...

How can I programmatically change a value in the Window's Registry?

I need to problematically change the "Level" String found in \HKEY_CURRENT_USER\Software\Intuit\QBWebConnector to "Verbose" What is the best way to do this? C#, bat file? I have never tinkered with the registry before... Thanks. ...

Can I mask an input text in a bat file

I am writing a batch file for execute some other programs. In this case I need to prompt for a password. Do I have any way to mask the input text. I don't need to print *** characters instead of input characters. Linux's Password prompt behaviour (Print nothing while typing) is enough. @echo off SET /P variable=Password : echo %vari...

How long a Batch file takes to execute

I'm wonderin' how I can write a script to calculate the time the script took to complete. I thought this would be the case, but obviously not.. @echo off set starttime=%time% set endtime=%time% REM do stuff here set /a runtime=%endtime%-%starttime% echo Script took %runtime% to complete ...

Passing a multi-line string as an argument to a script in Windows

I have a simple python script like so: import sys lines = sys.argv[1] for line in lines.splitlines(): print line I want to call it from the command line (or a .bat file) but the first argument may (and probably will) be a string with multiple lines in it. How does one do this? Of course, this works: import sys lines = """This...

Deleting temp files in batch file

Hey guys Just building a batch file to delete temp files on my vista machines @ home that i want to add to task scheduler. i have this so far, but i get alot of access denied, and it never finds a thumbs.db file or index.dat and there are heaps of them. what am i doing wrong? attrib +a -s -h -r "%windir%\Temp\*.*" /s del /f /s /q "%...