batch

How to make windows batch file pause when double-clicked?

Hi. I've written a batch file to automate some tasks. I can run it from a command window and it runs and displays results. If I double click it from explorer though, it runs and terminates immediately so I can't see the results. Is there a way I can make batch file window stay open until I dismiss it if I started it by double-clicking ...

Windows batch files: How to set a variable with the result of a command?

Under a bash environment I usually do: var=$(command -args) and the I use $var with its value setted as the result of the command. The same goes to a more conventional set var=command -args compatible in almost every unix shell. How could I define a variable in a windows bat file like that? I've tried set var=command -args but I only ge...

3 Level Batch Updates using NHibernate

Update: Batch updates are now working, but as I access children bags are re-read from db even though the enitites have be loaded. Using NH Profiler to watch is awesome. Unit Test: NHibernateSession.Current.Transaction.Begin(); var reservationEventIds = new List<int>() {123, 124, 125}; var repository = new Repository<Reserva...

Starting a Windows service in an interactive session

A colleague has a batch script program which needs to to run on a Windows Server in console mode, so that it has access to a Windows interactive session. The server is rebooted at regular intervals automatically (there's an unrelated closed-source application that runs on this machine that we have no control over). After a reboot he want...

How to run a script at random intervals

Hi I want to write a batch job in c# that runs a task at a random(ish) interval e.g. every hour +/- 20 mins and if no update is needed, then to wait x2 the last time before running again. What is the best method to do this? ...

Display text from .txt file in batch file

Hello, I'm scripting a big batch file. It records the date to a log.txt file: @echo off echo %date%, %time% >> log.txt echo Current date/time is %date%, %time%. @pause exit It can record it several times, on serveral lines. Now what I want to do is that the batch file file shows the last recorded date/time from the log.txt file. Ho...

batch file which asks for username/password + registration

I would like a batch file that can register a user into itself. something like: @echo off echo Choose an option: echo 1:Register echo 2:Login Set option= set /p option=Your option: if %option%==1 goto reg if %option%==2 goto login ... :reg --The registration script-- goto login ... :login Set usr= set /p usr=Username: if %usr%...

batch file which checks an entered text with text from a .txt file

I like to have a batch file which checks if an entered text in a .txt file is the same. Something like this...: @echo off Set pass= set /p pass=Enter your password: ...... ...... the .txt file is pass.txt and it should look something like this: p2342ddd3 So what i want it to do, that an user have to type in the text from the p...

Batch file which deletes a file which last modification was not today

I just wanna know: How can i delete 'log.txt' if the last modification was not today? With a batch file. I'm just talking here about 1 FILE! ...

How can a batch file locate where it is located?

How can a batch file by itself see where it is located? ...

mkdir -p Linux..Windows..?

hi all, thanks to all for ur valuable replies.. Also, in linux mkdir -p creates a folder tree.. What is the equivalent option in Windows( to create a folder tree) ? Is there any? Renjith G ...

Fastest way to delete a tree of empty directories in batch file

I need to write a batch file that received a directory that contains a huge number of empty sub-directories and deletes them all. What's the fastest way of doing this? (by fast I mean not like what Windows Explorer does when you try to delete such a directory...) Clarification: I'm not trying to delete only empty directories. It just ...

[NT Batch]How to get directory from user inputted file?

I need to know how to extract directory information from user inputted file, consider this code as example: ECHO Drag and drop your .txt file here, after that press Enter: SET txtfile= SET /P txtfile= ECHO. CD %txtfile% ofcourse that didn't work since i didn't extract filepath from %txtfile% and here the sample output i want: C:\>Dr...

Ignore question mark in .bat batch scripts

The thing is that I need to pass one parameter with question marks in it to a .bat batch file. If I use the question mark the parameter is not well passed. How can I solve this? I'm having troubles with this line: script.bat /n"output.owl" /r"http://www.address.com/blog/?feed=rss2" = symbol might be a problem too. ...

Problem with user input in my batch file

Hi, here is the portion of code giving me trouble: IF EXIST TH_BUILD_* ( ECHO A current build of Test Harness exists. set /p delBuild=Delete preexisting build [y/n]?: if "%delBuild%"=="y" (GOTO deleteandcontinue) else ( EXIT) ) For some reason, no matter the input, the batch file exits. Why is this happening (deleteandcontinue is nev...

Batch file: Password Stars/Circles

Like you already know, websites have certain special chars for passwords, like stars and circles. Could this be possible in a batch file, on the following one:? If this is not possible, if you type it in, could you just see nothing? set pass= set /p pass=Enter your password: if {%pass%}=={} goto :begin set authenticated= for /f "toke...

Redirect batch stderr to file

I have a batch file that executes a java application. I'm trying to modify it so that whenever an exception occurs, it'll write the STDERR out to a file. It looks something like this: start java something.jar method %1 %2 2>> log.txt Is there a way I can write the arguments %1 and %2 to the log.txt file as well? I don't want to wri...

batch for loop with bracket in the command

I have a batch file with the following code: for /f "tokens=*" %%a in ('dir /b /a-d') do ( echo Processing %%a >>%LOG% dtsrun /S(local) /NNotesLoad /A"FilePath:8="%NOTESDIR%\%%a" /AClientID=%1 >>%LOG% echo Deleting %%a >>%LOG% del %%a /q ) This is returning an error message of "/NNotesLoad was unexpected at this time" because the...

JDBC Batch Update Problem

Hi, I have a slightly unique requirement with the Java-JDBC API along with Oracle Database. I have autoCommit to be default which is true for Oracle and I am using the example similar to this link. However, when I add say 1000 batches and lets say each of them are inserts. And Let us assume that about 20 records violated some constraint...

What's a good way to write batch scripts in C#?

I would like to write simple scripts in C#. Stuff I would normally use .bat or 4NT .btm files for. Copying files, parsing text, asking user input, and so on. Fairly simple but doing this stuff right in a batch file is really hard (no exceptions for example). I'm familiar with command line "scripting" wrappers like AxScript so that gets ...