batch-file

How to insert the output of a command to variable in a batch file ?

Inside a batch file on Windows I would like some variable to have the output of dir /b command. How this can be achieved ? ...

How to identify which line in the batch file has a syntax error ?

I'm running a batch file on Windows and got this error: The syntax of the command is incorrect. Is that possible to identify which line in the batch file is incorrect ? ...

How to remove double quotes from a variable in a batch file ?

var may be double quoted: set var="Very long text" or without quotes: set var=Some_Text I would like to get the unquoted text, i.e. Very long text in the first case and Some_Text in the second one. How could I remove the double quotes, if exist ? ...

How to execute a scheduled task with "schtasks" without opening a new command line window ?

I have a batch file that creates a scheduled task using schtasks like this: schtasks /create /tn my_task_name /tr "...\my_path\my_task.bat" /sc daily /st 10:00:00 /s \\my_computer_name /u my_username /p my_password It works OK ...

Port Bash to Batch

At my school I want to automate the process of telling the students to go to class and play a song five minutes before class starts at the end of lunch. I wrote a Bash script that will play the announcement, a random song. After five minutes the script will fade out the music and kill VLC. I need this script run on Windows as the is the...

NAnt <exec> Task Always Returns 0 for Batch Files on Windows XP

I'm encountering an issue with the <exec> task on batch files in my NAnt project files. When running on Windows XP SP 3 (but not Windows Vista or Windows Server 2008) and using NAnt 0.85 or 0.91alpha2, the <exec> task will always succeed (returning an error code of 0) regardless of what the executed script returned. As an example, I wr...

Schedule Task : 6 months from now

Hi guys, I'm tryin' to find a way (from a batch file) that I can use to create a scheduled task that will execute 6 months from now. I've looked all over the net, and I'll I've come across is AT and SCHTASKS that will schedule the task monthly .. I'm looking for a solution that will execute this task every 6 months. I know this will r...

Escape characters in batch scripts

I have the following script to automate uploading a file to a remote server. The problem is that the password I have been given is full of special characters which are killing the login process. Here is a changed version of the characters. j7~]%&X When using a normal ftp app there isn't a problem. I have wrapped the password in ...

Simple Batch File Turns "é" into a Different Character

I have a batch file with a single line in it: src/Filé.txt When I run the batch file (either in the command prompt or by clicking it in Windows Explorer), I get the following: C:>src\FilΘ.txt 'src\FilΘ.txt' is not recognized as an internal or external command, operable program or batch file. It turned my é into an Θ! I've a...

SQLCMD in Batch Files - Force all output to one file

We have batch files to compile all the sql scripts in a folder against a database. Problem is that we have a couple of thousand scripts and it makes an output file for each script. It makes it difficult to check for errors and a lot to do cleanup on. Is there any way to output all of the results to one file? Here is the script we use: ...

Batch script to get website ip address?

I'm trying to put together a batch file, that will ping a website, and assign its ip to a variable - I've searched around, but haven't really been able to put something together. Can anyone shove me in the right direction. Tim. ...

Batch File Console

How Can I hide the console of a running batch file the batch is running from a cmd or start>run ...

netsh for whitlisting IP Addresses. 4000 IPs, how to add?

Using a little app, I have a few lines that look like the following: netsh firewall add portopening name = "__Auto_WebAccess_TCP_80_IPCount=501_0" protocol = TCP profile = CURRENT mode = ENABLE scope = CUSTOM port = 80 addresses = ip addresses , e.g. 84.22.55.22 and son on comma separated Problem is, the maximum characters you can put...

Windows: Execute Batch File for a Custom Context Menu Item

I am looking to add a new item in a right click context menu for a certain file type. I suppose it would be easiest to run a batch file with the full path of the file as an argument. I need to rename the file, unzip it, then rezip it, then rename it. I suppose winzip command line would be appropriate tool to help with that, unless someon...

Using a batch file to extract the variable part of a string to use in renaming txt files

I'm using batch files to process text files with names of the form: CLL*1.txt, CLLM*2.txt located in a specific "download" folder. All files contain a string of the form: "File Reference : 0xxxx", where xxxx is a unique numerical identifier. I am trying, without much success, to use the following script to rename the file to CLL*xxxx...

Checking whether a server is up or not using batch file?

I need to check whether a server is up or not? If down then i need to send an email And this task should be repeated in every 30mins. I have to do this using batch file. ...

Batch File to Delete Files in Folders

I have many folders in a directory that contain various files. Each filename begins with XXX_ where XXX could be the name of the folder the file is in. What I am needing to do is to go through all those folders and delete any file where XXX is the name of the folder that file is in. ...

Rename files using batch

I have a folder with files x_blah.blah y_ho.hum z_hi.ho which I just need to drop everything to left of the underscore and the underscore from so I'm left with blah.blah ho.hum hi.ho ...

Assign to a file a progressive number according to time

There is a way to assign to a file, lets call it abc.txt, a progressive number, that I suppose should come from the time set? So that the name of the file could become for example abc_5367879938763.txt ...

DEL saying path doesn't exist (it does)

I'm guessing this is a basic DOS question, its with the del command. All I want to do is delete a file. C:\Documents and Settings\matthewe\Desktop\testfolder>del C:\Documents and Settings\matthewe\Desktop\testfolder\test.pdf The system cannot find the path specified. I can guarantee that test.pdf exists, and the fact I'v...