batch

(Windows) Permanently altering a user's %PATH% via batch or Python

I'm packaging a Python project with setuptools and distributing it with easy_install, which allows me to place an executable file in a Scripts directory, hidden away inside the Python directory. For Linux users who run easy_install as root, there will be added a symbolic link in a standard bin directory (/usr/bin/, iirc). For Windows u...

SQLPlus variable definition

I want to do this in SQLPlus: define a file which contains today's date in its name and spool off the output of a SQL statement to that file. I know how to spool the output of an SQL statement to a file. Just don't know how to declare the file name as a variable containing today's date. For example, select all the rows with today's time...

C# Process.Start() Dialog Box for BAT file

I have a C# program that needs to spawn a .BAT command file during its execution. No problem. I can just use (for example)... System.Diagnostics.Process.Start("PublishFeed.bat", "file.xml"); ...in order to run the cmd with a parameter. In the debugger, this works fine. However, when I run the executable in production, Windows pops up ...

How can I change file encoding of the redirect file in a Windows batch script?

I have the following windows batch command as part of a larger batch file: type *.sql > dbScript.txt ren dbScript.txt dbScript.sql As you can see it joins all SQL scripts in a particular directory into one so that it can be executed during the database build process. My problem is that I now have non ANSI characters in one of the SQL...

Automatically Restarting a chat server application on system restart

I developed a chat application with an attendant chat server. Everything is working fine. The issue now is the fact that whenever the chat server goes down (for instance, the server system shuts down as a result of power failure or some other problem), by the time the server system come back on, the chat server would have to be restarted...

Can a IF condition be checked inside a FOR loop in batch file?

The code I need to implement in a Windows batch file is like this (it is currently in Perl): while(<file>) { if($_ =~ m/xxxx/) { print OUT "xxxx is found"; } elsif($_ =~ m/yyyy/) { next; } else { ($a,$b) = split(/:/,$_); $array1[$count] = $a; $array2[$count] = $b; $count++; ...

Batch Files - Error Handling

Hi, I'm currently writing my first batch file for deploying an asp.net solution. I've been Googling a bit for a general error handling approach and can't find anything really useful. Basically if any thing goes wrong I want to stop and print out what went wrong. Can anyone give me any pointers? Thanks in advance! ...

batch file equivalent of unix parameter expansion with quotes

There have been a lot of questions asked and answered about batch file parameters with regards to the %* but I haven't found an answer for this. Is there an equivalent syntax in batch files that can perform the same behavior as "$@" in unix. Some context: @echo off set MYPATH=%~dp0 set PYTHON=%MYPATH%..\python\python set BASENAME=%~n0...

Using DDD, How Does One Implement Batch Processing?

I have logic consisting of selecting a large number of records from one system, performing multiple transformations (based on business rules) and inserting them into another system. It seems like a high performance (and memory) hit to instantiate each of these records as an object, perform transformations on them and then insert all of ...

Batch code to re-name set of template files by changing part of the name of one file (all files to copy changes to the same text).

I have created a filing system containing folders as templates for re-creating a set of information to be used when we accept bookings and need a batch command to rename all files within a directory but in a very specific way. So to be more precise the directory contains: one file is an invoice template (PDF form) and another is a job d...

Using powercfg to duplicate the currently active power scheme

I need to run a batch file, with a series of powercfg commands to duplicate the currently active scheme and rename it. Manually, I would do something like this at the command prompt. powercfg -getactivescheme This would give me the GUID of currently active scheme. powercfg -duplicatescheme <GUID obtained above> <new GUID> Ideally,...

Batch file I wrote will not close automatically or on EXIT

I made this batch file to close explorer before launching Worms because for some reason my colors get messed up if I don't. The batch file works fine except that it doesn't close when it's finished. What did I do wrong? @echo off echo Closing explorer and launching worms taskkill /F /IM explorer.exe "C:\Games\Worms Armageddon - New Edit...

Batch Delete Files From File On Cmd Line

I have a long list of file names in a txt file, which I generated using findstr /M "string here" *.* > c:\files.log The file is about 3mb. Now i want to delete all of those files. I tried del < c:\files.log but that doesn't work. What should I use? ...

How to assign chdir to a variable in .bat?

I'm trying to translate a bash script into a .bat script. The specific line I'm tripping over is this: X=`pwd` What is the .bat equivalent? I need to take the directory that the script is currently running in as a variable so I can use a generic relative path to find files in the directory. I'm running on Windows-XP in the command ...

Error Running a Batch File To Copy A File

I am trying to run a batch file to copy a backup file from one location to other. I keep on getting the error: Invalid drive specification My path is as follows: \\server\drive:\folder\folder\folder\*.bak drive:\folder\.bak ...

%~$PATH:1 expansion issue

So I recently stumbled on the (potentially) useful %~$PATH:1 expansion, however I seem to be unable to make it work correctly. I tried to use it to make a cheap Windows version of the which command, however the syntax seems to be defeating me. My batch file looks like this: @echo off echo %~$PATH:1 However when I run this with for exa...

Getting windows to start R in batch mode using the Start command

I know I must be making a simple syntax mistake, but I want to have a windows batch file that fires up 9 instances of R and runs a different routine in each one. I want these to run simultaneously (i.e. asynchronously). I can fire up 9 command prompt windows and type a command in each one, but it seems like with the START command I shoul...

Batch Scripting, For using the results of a dir

Hi All, I'm trying to write a small batch script that will delete files old files from a directory. The first parameter is the directory for the script to look into, and the second is the number of files to preserve. rem @ECHO OFF rem %1 is the path in which to look for the files rem %2 is the number of recent files to preserve if [%...

windows batch script format date and time

In a windows (XP) batch script I need to format the current date and time for later use in files names etc., Similar to http://stackoverflow.com/questions/864718/how-to-append-a-date-in-batch-files but with time in as well I have this so far: echo %DATE% echo %TIME% set datetimef=%date:~-4%_%date:~3,2%_%date:~0,2%__%time:~0,2%_%time:~...

Batch file to execute a program for particular time period

Trying to Create a batch file through which I start this program to monitor processes for example at 1 a.m and continues for an hour and than around 2 a.m stops this program and saves the log file to specific location. START /MAX C:\Procmon.exe want to do a research on this whether its possible or not. Don't want to put much time on th...