batch

SQL Statements in a Windows Batch File

Is there any way to have a Windows batch file directly input SQL statements without calling a script? I want the batch file to login to SQL and then enter in the statements directly. EDIT: I'm using Oracle v10g ...

A .bat or .wsh script that can search for files

I am looking for some examples of a .bat OR .wsh script that can do the following: Recursively read file names in a directory with a user-provided extension (.dll, .exe, etc) Search a user-provided directory for the above file names Generate a txt or xls report of the findings, like: x.txt was found in "C:\temp", "C:\blah" TIA. EDIT...

Delete certain lines in a txt file via a batch file

I have a generated txt file. This file has certain lines that are superfluous, and need to be removed. Each line that requires removal has one of two string in the line; "ERROR" or "REFERENCE". These tokens may appear anywhere in the line. I would like to delete these lines, while retaining all other lines. So, if the txt file looks...

http web request from batch file

I need to execute a http web request from Plesk's Task Scheduler (using shared hosting on Windows/ASP.NET; no Powershell, whatsoever). Thought about using a batch file for this. Is there an easy way to do this? ...

Scheduled Task: Directory cleanup using windows batch script

I have a shared disk that I would like to clean up once per week using a scheduled task of some sort. I would like to use a batch script so that the system admins can easily modify it or reuse it on other directories when needed. The directory has files with multiple file extensions but the ones that need to be deleted end in .bkf and m...

Batch files, vista x64, if and parenthesis

Some batch files on Windows use an IF syntax with multiple lines, as below: if var==rule ( some comands ) else ( else commands ) Now, Windows Vista x64 decided to put all 32 bits files under "C:\Program Files (x86)". Unfortunately, whenever you use an environment variable (such as PATH) inside a multiple line IF without quotes, th...

xcopy at logon

Our client are having problems when logging in on their WinXP (fully updated) computers. We run a batch script that copies files and folders using xcopy. No files are copied, but folders are created. If I run the xcopy manually then there is no problems. One of the source folders have non-english characters in its name. After I removed...

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

How can I get the value of a registry key from within a batch script?

I need to use a REG QUERY command to view the value of a key and set the result into a variable with this command: FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "KeyName" /v ValueName') DO SET Variable=%%B But if the key doesnt exists i get an error shown in the console. I need to hide this error! I tried putting a 2>nul after the...

batch not working if calling from a Java program

I wrote a batch file that reads in a text file which contains a list of file name, and then delete and rename them one by one. I did this by using a for loop, and it works perfectly by double clicking it. But when I tried to call this batch from a Java program. It's no longer working for this part: for /f %%a in (ListFile.txt) do ( ...

In Batch: Read only the filename from a variable with path and filename

I am currently looking for a way to take a variable in batch and only parse out the filename. For example, I pass my batch file a -s parameter from another application which is subsequently set to my source variable. The source file variable typically contains something like: C:\Program Files\myapp\Instance.1\Data\filetomove.ext. I ass...

How to capture stderr on Windows/DOS ?

I want to capture the errors from a script into a file instead of to the screen. In *nix, this is done with stderr redirection, usually echo "Error" 2> errorfile.log How do I do it in CMD script under windows? Thanks! Miki ...

Problem with windows Batch file on windows 7

I have a batch file to compile and link all of my code. It contains the following: @echo off nasm -f aout -o start.o start.asm gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno...

How can I make a Windows batch-file which changes an environment variable?

Is it possible to make a batch file which can make a persistent change to an environment variable? For example my installer.bat script copies some files to a random location in the computer's file-system. I'd like to add that location to the PATH environment variable so that the programs can be run in the current session. FYI - the st...

Can a python script persistently change a Windows environment variable? (elegantly)

Following on from my previous question, is it possible to make a Python script which persistently changes a Windows environment variable? Changes to os.environ do not persist once the python interpreter terminates. If I were scripting this on UNIX, I might do something like: set foo=`myscript.py` But alas, cmd.exe does not have anyt...

How to hide the console of batch scripts without losing std err/out streams

My question is similar to Running a CMD or BAT in silent mode, but with one additional constraint. If you use WshScript.Run in vbscript, you lose access to the standard in/error/out streams of the process. WshScript.Exec gives you access to the standard streams, but you can't hide your windows. How can you have your cake (hide the win...

Setting cmd.exe /V:ON flag without starting new instance

Is there any way to enable execution-time variable expansion for cmd.exe (normally done by typing cmd /V:ON) without starting a new instance of cmd.exe? Similarly, can other settings/flags be changed on the fly? ...

pipes in Visual Studio build events

I'm using Visual Studio 2005 Express Edition with SP1. I have a Pre-Link Event which needs to invoke one program and send its output to another. foo | bar This command works as expected when invoked from a command line or batch file. The command fails when invoked from the Pre-Link Event (even if the Pre-Link Event invokes a separate...

Clear Internet Explorer 6.0 browsing history using Script

Hi, I was using the following script to delete the browsing history in IE 7.0 RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 But now I need a script to clear browsing history in IE 6.0 I get an error that "missing entry ClearMyTracksByProcess" I have passed different parameters like 2 ,5 etc and wasn't successful. ...

How do I echo and send console output to a file in a bat script?

I have a batch script that executes a task and sends the output to a text file. Is there a way to have the output show on the console window as well? For Example: c:\Windows>dir > windows-dir.txt Is there a way to have the output of dir display in the console window as well as put it into the text file? Thanks ...