FAQ Database Discussion Community


Batch script ends after for loop

windows,batch-file
I've got a batch file that executes a program along with sequential (numbered) macros and calls another batch file that monitors when it is finished before it begins the next iteration. I can't use Start /wait or other "ordering" commands when launching the program because it is started with a...

How to take name from file with specific extension and use it as variable in batch script?

windows,variables,batch-file
Can anyone tell me how to take name from specific file with specific extension (.pdf) and use it as variable? Thanks in advance...

If exist and errorlevels in a batch (.bat) file

windows,batch-file,command-line
I'm trying to run a delete command on the result of an SQL command but only if it returns an error code of 0. Below is my code: SqlCmd command... REM if SqlCmd command is successful run the below if exist statement if errorlevel 0 ( REM if the file...

Passing argument to python script within a batch file in Windows

python,batch-file
I have a python script that can be called in Windows as: python.exe do_my_work.py param > output.csv param is an input parameter. I also have a txt file called params.txt that contains many lines, each line is a value for the parameter of the python script: hello world this is...

Batch file to delete all folders in a directory except the newest folder

batch-file,backup,folders
I am trying to delete old backups in a specific folder after a new backup has been done. As i do not really have experience with DOS commands i mashed a couple of scripts i found on the internet into one: ::(C)2008 "BuckFix" www.winsupportforum.de @echo off setlocal set workdir="M:\BACKUPS\CACHE_SSD\" set...

Getting Respond Time from Ping Command

batch-file,ping
I'm trying to create a batch file that will ping a certain server and will only display the respond time. I don't mind if value is stored in a variable or not. If you do a normal ping you get: Reply from <hostname/server>: bytes=#byte_value time=#time_value TTL=#TTL_value And I only want:...

String check incorrectly returning true

batch-file
So I have been playing around in batch trying to make a simple batch game. So now what have I done wrong? Here is the code: :promotions_sucessful cls if %division%==Bronze V ( set league=Bronze IV set lp=0 echo You have been promoted! del promotion.txt pause>nul goto menu ) if %division%==Bronze...

How to convert or separate text file into column format records like excel or csv

batch-file
Thanks in advance.. I have one text file which contains SQL records separated by pipe'|'. I want each record in separate column. For example the text file contains above data :- Name|address|status John|USA|A1, active Bob|UK|A3, active Merry|NYC|A2, active I want to convert it to excel using batch script. I don't...

Batch files - List of variables [closed]

batch-file
Where can I find a list of common variables and commands used in batch files? For example %USERNAME% or %USERDOMAIN% or a list of switches and what they do. I would like a comprehensive dictionary or something where I can find useful things. Can anyone point me in the right...

Create batch script to edit host file by network connection

windows,batch-file,cmd,network-programming
I want to use this batch script to add new entries into my host file automatically by using windows batch. I want to edit host file only when i m in office. I want to say like that: if(network name=='OfficeWifi') do changes... @echo off set hostspath=%windir%\System32\drivers\etc\hosts // if(network name=='OfficeWifi') echo...

Echo of time not displayed at end of batch file

batch-file,time,echo
Here is my batch file: @echo off set start=%time% echo %start% for /d %%i in (*) do ( mkdir "%1\%%i" cd %%i for %%j in (*.mp4) do ( echo "%1\%%i\%%j "..\ffmpeg32" -loglevel panic -i "%%j" -c:v libx264 -preset fast-crf 50 -c:a copy -y "%1\%%i\%%j" ) cd .. ) set end=%time%...

Can I separate some long expression of BAT file into several lines?

batch-file
How can I split some long expression of BAT file into several lines (for convenient reading)? For example, I have a long line: call "%NUNIT%\nunit-console.exe" /out="%~dp0%file_name%.out" /err="%~dp0%file_name%.err" /noshadow /xml="%~dp0%file_name%.xml" "%~dp0%file_name%.dll" I want to get the more readable variant, for example three lines instead of one: call "%NUNIT%\nunit-console.exe" /out="%~dp0%file_name%.out" /err="%~dp0%file_name%.err" /noshadow...

Is there a way to output file size on disk in batch?

file,batch-file,filesize
Is there a way to get the size on disk of a file like in the properties window: I have tried: (inside a batch file) echo %~z1 , for %i in (TestFile.txt) do echo %~zi , dir But they only return the size of the file(s). Is there any way...

What could be the reason for error message Unexpected Goto in batch file with many string compares?

batch-file
Here is the code of my batch file: :add_game_now cls echo Add a Game! echo V for Victory and D for Defeat set /p add_game= if %add_game%==V goto add_game_now_v if %add_game%==D goto add_game_now_d :add_game_now_v set /a elo=%elo%+20 if %division%==bronze goto add_game_bronze_v if %division%==silver goto add_game_silver_v if %division%==gold goto add_game_gold_v if...

Catch result of process from exe (right click context)

batch-file,command-line,cmd,registry,right-click
I wrote following reg file inorder to delete files/folders securely. Cmd working as expected. But sometimes I would like to see result of it (I do not want to disappare of cmd window) How can I pause / wait / stop before windows disappared "D:\Desktop\_NotUse\SDelete\sdelete.exe -s -p 5 \"%1\"" /pause...

SendTo / Batch / 7zip

windows,batch-file,7zip,sendto
I am trying to create a SendTo shortcut to a batch script that will take the selected files (in this case, jpg's), zip them with 7zip and name them the folder name (that the selected files are in) and place them in the same folder. The directory names have spaces...

create a xslt 2.0 transformation pipeline with batch file

xml,batch-file,xslt
I have around 20 xsl scripts which need to be executed in a certain order. They each produce an output document that is the input document for the next stylesheet. I only know very basic batch scripting`(mkdir, cd, a simple for loop,...). What would be the best way to do...

Batch File Return Codes with executables

batch-file,exe
Possibly a really dumb question: If a batch file runs an executable and the executable fails, does the batch file return the error code of the executable or does it return 0 for finishing its code? (or some other return code?) Relevance: I'm created tasks for a task scheduler to...

Batch script terminates in case of error when using pipe operator

batch-file,error-handling,pipe
I need to perferm error handling (check ERRORLEVEL) on an operation involving the pipe operator, but instead of the script continuing with a non-zero ERRORLEVEL, it terminates immediately. How can I avoid this behavior? Consider the following example. (Note that is a simplified constructed example to illustrate the problem -...

truncate log with robocopy

batch-file,robocopy
I am running a robocopy process, and generating a log as follows: robocopy "\\server1\reports" "c:\temp" /LOG+:"c:\scripts\logs\robolog-reports.txt" The log file is created fine. Is there any way to limit the file size of the log file, ideally rolling the log so that only the newest XX lines or XX bytes are...

Changing input path in Batch - path manipulating/modification

batch-file
I have a simple batch like this: SETLOCAL @echo off SET sourceRoot=d:\SVN\Project\Debug\General\ServicePortal\bin SET destinationRoute=d:\SVN\Project\Debug\General\Admin Project\ I can pass "d:\SVN\Project\Debug\General\Admin Project" through parameter to the bacth, but I don't know how can I cut the last folder "\Admin Project" and combine with "\ServicePortal\bin". Is it possible? Thx in advance...

Counting lines in a text file; use result to split text files into sections

batch-file
Using Windows batch or possibly another language I am looking to split a text file containing 85K+ results into separate text files. There is also a header at the top that needs to be present on every new text file. The short but only code I have and can get...

Batch-Script: Replace every [email protected] in file name with “_” in network drive including subfolders

batch-file,replace,folder,filenames
My Problem is this: I want to replace every Special character such as "@" in file names. Example: old file: [email protected] new file: test_home.txt This should be done in a special chosen Folder including subfolders. The user should easily Change the Location (Folder). Thx guys Alright Well, I will give...

I cannot use the msg command in cmd (or batch for that matter). How can I fix this?

windows,batch-file
While in cmd or making a batch file, I cannot use the command msg. When I try to use it, it returns the error msg is not recognized as an internal or external command, operable program or batch file." I'm pretty sure the error is that im missing a msg.exe...

IF statement in FOR loop not working

batch-file,cmd
I am creating a batch file to initialize a portable game and run it locally on a computer for performance purposes, and another script to save the game to the portable drive when finished and check for updates. Batch File (save, update, & clear local cache) @echo off title Minecraft...

Execute multiple command lines with multiple arguments

python,windows,batch-file,python-3.x
I can't figure out why my command lines doesn't function. I tried subprocess.Popen()` function : `Popen('C:/Test/test.exe -scan "C:/Users/Vince/test.txt" "C:/Users/Vince/test.xml"', cwd='C:/Users/Vince/Working_Directory') But when I run a batch file from my Python program by using os.system("E:/test.bat"), it functions. Here is the content of my batch file: C: cd Users\Vince\Working_Directory C:\Test\test.exe -scan "C:\Users\Vince\test.txt"...

Win7 Batch File - Moving Subfolders(& Files) to Grand-Parent Directory

batch-file,cmd,merge,move,subdirectories
I have a somewhat complicated problem. I've downloaded an archived website from archive.org using Httrack and now I have thousands of subfolders and files I need to merge before I can rebuild it. I'm trying to write a batch file to solve the problem. But my search results never come...

Where should i place .bat file to run through java code?

java,batch-file
I'm trying to run First.bat file through java code but I'm getting error(Warning) popup that says Windows cannot find First.bat. Make sure you typed the name correctly, and then try again. Can anyone tell me what kind of error is it and where do I exactly place .bat file to...

Variable setting exhibits unexpected behavior when set inside for loop

batch-file
I am modifying a batch script to pass a file location to a makefile (run with nmake). The for loop is supposed to loop over available drives and search for the file if it hasn't been previously set. Batch isn't something I have much experience with, so hopefully someone can...

Fastest way to count lines in a file

batch-file,dos
I have huge CSV file, which I want to know the total number of rows in which. Currently I am using something like this, which works perfectly, but it's slow: FIND /c ";" FILENAME.csv But I dunno if that's the fastest way to iterate through all lines in a CSV....

How to start a string using BATCH

string,batch-file
I'm trying to make a program that will search google for what the user had typed in to i created this: @echo off set "str1=www.google.co.uk/search?q=" echo What shall i do? set /p Input= set "str2=%str1%%Input%" Start "str2" Pause :END The problem is that when is starts "str2" it just opens...

Broke my script

batch-file
I tried to get the Ping script also in my Batch script, but now it doesn't work anymore. @echo off title Windows Fix Script BETA - Running as Admin check if "%2"=="firstrun" exit cmd /c "%0" null firstrun if "%1"=="skipuac" goto skipuacstart :checkPrivileges NET FILE 1>NUL 2>NUL if '%errorlevel%' ==...

Batch Random Pinging(Trying to determine if a ping is successful)

batch-file,random,ip,ping
I have made a program that creates random IPs and pings them to see if they exist. It records the output using '>' and '>>'. I want to check if the ping times out and if it does exclude it from the text document. This is my code so far:...

Batch ffmpeg and compress the files

batch-file,ffmpeg
I am doing a bunch of conversions with ffmpeg, where I need to watermark the content. I am using a batch file to run the ffmpeg application, but I want to automate all of this. for %%a in ("*.mp4*") do ffmpeg -i "%%a" -i logo.png -filter_complex overlay "newfiles\%%~na.mp4" pause Source...

Get the PID of a Windows service by the name of the service

windows,batch-file,service,cmd,pid
Is there a way of getting the PID of a windows service with a command in a batch script by just knowing the name of the service?

Batch - Comparing two txt files

windows,batch-file,text,comparison
I have some difficulties comparing two txt files with batch. I used the "findstr" function with many option matchings but none works (for example FINDSTR /I /V /B /G:file1.txt file2.txt). I have a first txt file as following: File1.txt Object 1 Argument 50 Object 2 Argument 10 Object 3 Argument...

execute the NETSH WLAN SHOW ALL command with pauses

batch-file,cmd
I'm creating a batch program of which one function is to show all properties of the wlan, however, when executing the command NETSH WLAN SHOW ALL all output goes by so fast half of it can't be read. I was wondering if there is a way of adding pauses during...

Batch File Pass Delayed Variable Expansion As Argument

batch-file,delayedvariableexpansion
I have a batch variable, which contains the name of another variable. When I perform a CALL ECHO on the variable, the output is what I expect. However, when I try to pipe the output of the CALL ECHO command as an argument to another command, I am running into...

Garbage char returned by Shell.StdOut.ReadAll

batch-file,vbscript,stdout
Here is my code Set objFSO = CreateObject("Scripting.FileSystemObject") a = "@echo off && " & _ "pushd ""\\xxxxx.local\cfs\Development\Docs\Baseline"" &&" & _ "cls &&" & _ "dir /b /a-d &&" & _ "popd" Set objShell = CreateObject("WScript.Shell").Exec("%comspec% /c " & a) execStdOut = objShell.StdOut.ReadAll() msgbox execStdOut Basically I am trying to...

Batch - xcopy files older than x minutes

batch-file,time,copy
after a new file creation time of 20 min I want to copy all files with the extensions .txt from Folder New to Folder Target. (I want to copy olny files are older than 20 min) So far, it looks like this: set hh=%TIME:~0,2% set mm=%TIME:~3,2% set ss=%TIME:~6,2% set /a...

Execute SVN Update in Jenkins - Copy a Folder to Web root Explicitly from SVN as a Build Step

powershell,batch-file,jenkins,jenkins-plugins
I'm new to Jenkins CI.I'm trying to get SVN update (myFolder) inside a job as build steps. I want to explicitly copy some files to web root as I can't have them inside my solution. Build Steps I need to perform. Build Solution Publish Copy myFolder to web root Sync...

Is there a way to close a single window of a process from a BAT file?

windows,batch-file
Here's my situation: I have my Windows 7 computer set up so that every morning, a task runs that plays my alarm and causes my morning routine to open up (in a WordPad window). The thing is, I would like to also have the window automatically close at the time...

My batch files if else statement isn't working

batch-file,if-statement
So I have created a file that works and when testing it without the if/else statement. When I put in this in a if statement it doesn't work at all though, is my syntax wrong or what? Thanks. @echo off set /p id= Folder Name: set /p yn= Subfolders? (y/n):...

Execute a batch file before executing in a shortcut (.lnk)

windows,batch-file,lnk
I have multiple versions of a program called Siemens NX. NX uses environmental variables for configuration. I need NX 10.0 to use a different set of environmental variables than my NX 7.5 which uses the system environmental variables. Therefore, I have written a batch file that setups the environmental variables...

Create a bat file that will run git and then run script

git,batch-file
I'm trying to write a batch file that when I run it will clone a repository locally. To open the git I have the following command: C:\Windows\System32\cmd.exe /c "%LOCALAPPDATA%\Atlassian\SourceTree\git_local\bin\sh.exe" --login -i However no matter what command I put in after this it never runs. I have read somewhere that this...

batch result me “echo off” instead the proper result

batch-file,cmd
I have a little problem with the next code @Echo off Title STARTING cls echo. echo Checking running services... echo. timeout /t 2 /nobreak >NUL tasklist /fi "imagename eq cmd.exe" /v | find /I /N "DATABASESERVER" >NUL if "%ERRORLEVEL%"=="1" ( cls echo. echo Database is not running, now will start!...

How to extract a string from the first line of a file using batch?

windows,batch-file,cmd,batch-processing
I have these files that contain a name in the first line I wish to extract. All the methods I have approach either result in error or give me nothing. An example file can be found here: https://www.dropbox.com/s/0kcgj8vr3wii33s/FORS2.2011-10-23T23_59_20.355_out.fits?dl=0 I wish to extract "PN-G013.3+01.1", which lies on the first line (column...

Reading lines from .txt into batch file and handing into command line as arguments?

python,batch-file,command-line-interface,command-line-arguments
I need to read each line of a .txt file, line by line, handing in each line as an argument to a process I'm running in the CMD line interface. In the command line it would look like: "process c:/script.js arguments". I originally did this using Python: with open("C:\path\to\document.txt", "r")...

String manipulation with batch scripting

windows,string,batch-file,space
I need to save the variable in %%c temporarily which comes from a for loop. But when I try to do that, the content changes unexpectedly. Some space characters appear at the end of the string. The content of %%c is a.jpg by the way. echo %%ca REM prints a.jpga...

Recursive check files and perform zip if a particular file type exists

windows,powershell,batch-file,recursion,cmd
My Problem statement: Main Folder -SubFolder1 --1.jpg --2.jpg -SUbFolder2 --Subsubfolder ---1.jpg ---2.jpg I have this main folder which has subdirectories and at the last subdirectory, there are images. Now, what I wish to achieve is recursively check if image file(s) exists in a subdirectory If it does, zip all the...

How to wait until my batch file is finished

c#,windows,batch-file,cmd,wait
I'm doing a program where I need to start cmd and there start up a batch file. The problem is that I'm using MyProcess.WaithForexit(); and I think it does not wait until the batch file processing is finished. It just waits until the cmd is closed. My code so far:...

PSQL Error Level in Batch For Loop

batch-file,for-loop,postgresql-9.3,psql
I am attempting to run a postgres query from within a batch file. However, I have thus far been unable to detect when the command fails. The following is what I have tried thus far: @FOR /F %%A IN ('PSQL -U userName -d dbName -t -c "SELECT * FROM nonExistantTable"...

Batch Yes/No option

batch-file
I'm busy to build a script for myself which empties different folders but I want make a Yes / No choise for the user where N goes back to the menu and Y runs the script. This is what I got: :temp CHOICE /C YN /M "Enter your choice:" IF...

batch file for runing a java command

batch-file,docx
I have to run the following command for hundreds of .docx files in a directory in a windows in order to convert them to .txt. java -jar tika-app-1.3.jar -t somedocfile.doc > converted.txt I was wondering if there is any automatic way such as writing a ".bat" file to do this....

problems with multiple comands in one batch file

windows,batch-file
I'm new here so be gentle :) I'm trying to write patch file starting in batch and with to convert that to exe once completed. i have 2 batch files that work just great when executed separately but when i join them in one the 2nd part of batch file...

Batch file to retrieve filenames from a text

batch-file
I have a text document with a couple different file extensions used repeatedly. I would like a batch file to extract all the filenames (.jpg, .txt) and create a list. I have never worked with batch files before, but I don't think this should be too difficult. Sample: input.txt :...

find common string in two text files using batch script

string,parsing,batch-file,search,replace
I'm trying to find common string in two text files. For example, first text file contains following 1.txt //documents #5 ##text //documents/A #6 //documents/B #7 second text file contains following: 2.txt //documents/A #3 output.txt //documents/A #6 If common string found, expected output last number taken from 1.txt file. try.cmd @echo...

Formating issue with md5deep

batch-file,hash,md5
So I am making a program in batch and it requires a text file to be hashed then the hash has to be saved to a text file. I already have that part done but when it saves to the text file it saves like this f558e01b798b0390ab6206679a6926a7 C:\Users\computer\Desktop\tmpfile.txt So my...

Delete files from folder [Windows]

windows,batch-file
The problem is as follows - I have a text file with an imagelist which contains the names of photos. The photos reside somewhere else on a hard drive. How do I delete/move those photos which names are in imagelist? Is there any batch routine?...

How to select multi-line strings (including spaces), return true if found - PowerShell/SQL Batch

sql-server,powershell,batch-file,powershell-v2.0,powershell-v3.0
I have used select-string to validate strings found on one line, however I need PowerShell to recognise multi-line strings, as well as meeting all three conditions (see below) Output within .log file that needs to be selected: Return Value ------------ 0 I would want something to validate the following string...

Batch file to check program installation

batch-file
I am trying to determine if some program has been installed and, if it has, open it. If the program has not been installed, an alternate program should open. For example, if Notepad++ has been installed, the script should open that; if not, Notepad should be opened instead. Any advice...

.bat - insert text before a period

batch-file
I have a .bat that I use to quickly query basic information from servers. After it gets the FQDN from DNS, I need to insert a "-r" (minus quotes) after the servername, but before the ".domain.com". The area that it will be added to the script is below - for...

Create a batch file to change the power options in Windows 7

batch-file
Is there a way to create batch file and place it on the desktop to change the power options in Windows 7? Specifically I have the computer set to sleep after 30 minutes. Now that I use "Serve To Me/Stream To Me" apps I want to quickly be able to...

Batch file to open multiple instances of cmd and run Ruby script in each instance

ruby,windows,batch-file,cmd,watir-webdriver
I'm trying to open multiple instances of cmd up which each run a ruby script at the same time. For background into the scripts, each of these ruby scripts run watir-webdriver and spawn new browser instances. All of this should happen instantaneously. Here's what I've tried: start cmd /k cd...

Windows script batch to copy files from different folders to other folders

windows,batch-file,cmd
The easiest way to explain the problem is by an example. I want to do something like this: file x in /path_1/A/x copy in /path_2/A/ file x in /path_1/B/x copy in /path_2/B/ ... ... file x in /path_1/Z/x copy in /path_2/Z/ From command line with a script in Windows....

How to properly report an exit status in batch?

python,windows,batch-file,exit-code
I'm facing a weird situation where a batch file I wrote reports an incorrect exit status. Here is a minimal sample that reproduces the problem: bug.cmd echo before if "" == "" ( echo first if exit /b 1 if "" == "" ( echo second if ) ) echo...

Open website url links with parameter by using a batch file

url,batch-file,parameters
I am trying to open some website url links with a parameter in my browser. I made a batch file using this code : @echo off start "images" "www.images.com/1000/image.jpg" start "images" "www.images.com/1001/image.jpg" start "images" "www.images.com/1002/image.jpg" ... ... start "images" "www.images.com/5000/image.jpg" All I want is to create a For loop that...

How to compose Python exe programs using pipes?

python,python-2.7,batch-file,command-line,pipe
Python newbie here. I created a Python program, msg.py, which outputs a message (Hello, World). I created a Python program, id.py, which reads input and outputs it. Using py2exe I created an executable of each of them: msg.exe and id.exe I created a DOS batch file, set PATH to the...

Logstash exec input plugin - Remove command run from @message

batch-file,logstash,logstash-configuration
I'm using logstash 1.5.1 on a windows machine. I have to make a rest call, that delivers me JSON output. Therefore I'm using exec. The result is no json anymore :-(. The @message of this event will be the entire stdout of the command as one event. https://www.elastic.co/guide/en/logstash/current/plugins-inputs-exec.html My logstash...

Convert batch command to python

python,batch-file
I am trying to convert a .bat file to python, almost everything is working fine, only the compression part is not working, I point out the flags and the path to the "rar.exe", but it's not working at all in the python version. What I need to correct to have...

How to show the place and only the words found Findstr?

batch-file,findstr
I wonder how do I show the location where the words were found in findstr? My Code: Set "LFiles=%temp%\Files\*.txt">nul 2>&1 Findstr /li /G:"List.txt" "%LFiles%">"Result.TxT" (for /F %%a in (List.txt) do ( Findstr /li /C:"%%a" "%LFiles%" > NUL if not errorlevel 1 echo %%a ))>"Result2.TxT" List: Disc Music Song Album Result:...

Wildcard with Service Stop/Start

batch-file,tomcat,kill
I know we could do this in VBS, PowerShell, etc. However, we do not want to do this with another language other than good ol' batch script. Have figured out the following: TASKKILL /F /IM "tomcat*" And this will forcibly kill/stop any persistent instances of Tomcat. Also, this would cover...

Batch md command

batch-file,cmd
I'm trying to copy contents of a cd to x86 of my computer. When I run my script it says "A subdirectory or file \Navel already exists". When I navigate to my x86 folder my file isnt there. How do i fix this. cd %ProgramFiles(x86)%\ md \Navel pause ...

Replace the part of the path by string in specific file type in a folder

windows,batch-file,cmd
In U:\mtproject\obj\ folder and sub-folders having *.def files. I need to get those file paths and print in the command prompt. but before print I need to replace the U:\mtproject\obj\ part by E:\backupDir\DefBackup\. Here is what I tried and set objdir=U:\mtproject\obj\ set backupdir=E:\backupDir\DefBackup\ for /r %objdir% %%f in (*.def) do...

Batch For Do Test if exist rename url link on desktop

batch-file,for-loop
Why does this not work? I want to test each users desktop for a file and then if it is there, rename it. FOR /F "tokens=*" %%G IN ('DIR c:\users /B') DO if exist "C:\Users\%%G\Desktop\My Link With Spaces.url" ( rename "C:\Users\%%G\Desktop\My Link With Spaces.url" "My NEW Link With Spaces.url" )...

Filtering with Multiple Coloumn Variable List

batch-file
We are using a very simple query command to get a list of variable, and the format is quite similar (i.e- 004852 (space) E (space) [email protected], 004879 (space) BLANK (space) [email protected], 004883 (space) E (space) [email protected], 004892 (space) BLANK (space) [email protected]) like that, and we are using simple this line...

Format a command in powershell including a comma, can't find the right way to escape

powershell,batch-file,escaping,powershell-v2.0,comma
I have a command that I need to run in a Powershell script, the command is : ".\pacli DELETEUSER DESTUSER='"[email protected]`,com"' sessionid=333" | invoke-expression The comma (,) in here :[email protected],com is not a mistake, and that's what is giving me the hard time. I tried to escape the comma with `...

How to pass a variable into %0 part of batch file with ftp?

windows,batch-file,cmd,ftp
I have a batch file I want to be able to call from the command line like: myBatch.bat testParam That batch file is the following: set sid=%1 C:\Windows\System32\ftp.exe -s:%0 goto done open servername username password get 'FilePath%sid%restoffilepath' targetPath\%sid%MyName.txt bye :done However, I cannot seem to get the FilePath%sid%restoffilepath part to...

Parsing the text file line-by-line using batch script (batch file)

windows,batch-file,scripting,cmd
So, I am programming in the batch script and I came across this issue. The following code will take yourwords.txt file and parse it. The existedWord variable will have the last word of the text file. So, everytime when I run this program it will only compare the user's input...

Batch file %%i was unexpected at this time

variables,batch-file
I am trying to get a patch file to set a variable to the number of instances that are running for a particular executable but am getting this error: %%i was unexpected at this time Here is my code: for /f %%i in ('wmic process where name="chrome.exe" ^| find "chrome.exe"...

Batch file to conditionally execute ifortvars.bat

windows,batch-file,cmd,fortran
I am using a make.bat file to compile my Fortran code. To compile using the ifort command, I first need to initialize the compiler by executing ifortvarsbat intel64 command where I had to setup the path variable. This works fine, however, the path keeps increasing in size and says command...

Checking Blank User Input in Batch file (No Input) [duplicate]

windows,batch-file,cmd,scripting
This question already has an answer here: set /p empty answer crash 1 answer So, I am asking the user to make an selection. The point of this question is to catch if the user hit just entered without any input. My plan is to find out if the...

bat file script to check if string contains other string

windows,batch-file,cmd
I need to write a batch file that will check if a variable contains specific value. I tried to do the following: If "%%a"=="%%a:%pattern%" ( echo Yes ) else ( echo No ) input example: %%a="bob binson" %patern%="binson" I never get Yes printed! can anyone please tell what i missed...

Implementing timed input in batch file. (countdown to a minute)

windows,batch-file,cmd,countdowntimer
I am using windows 8 to write a batch file and I got stuck in implementing the timer in batch file. I want to ask input from the user and give them one minute to type their input. Once the time hit a minute then display message like 'the time...

Change OS Language Silently (Windows 7)

powershell,batch-file,registry,windows-7-x64,regedit
I'm writing a script (powershell) for SQL Server 2014 Express Install. The problem is: I have to change the OS Language (Region and languages) to fr_FR (French from France) Silently. The current language is fr_CA (French from Canada). My question is: Can i change the language from intl.cpl (Region and...

Batch script ignores %ERRORLEVEL% or using previously set one

batch-file,process,errorlevel
I wrote a batch script to find out if a specific process runs on a computer:     for /f %%a in (computers.txt) do (     PsList.exe \\%%a -e "process" > result.txt     Find /i "found" < result.txt     IF "%ERRORLEVEL%" == "0" echo %%a >> Computers_without_process.csv...

How do i handle ERRORLEVEL 9 in cmd

batch-file,batch-processing
I have developed a batch script which checks for the version of the software installed on a machine and based on the version it picks up the correct version patch and installs it (runs) on the machine. However i am facing an issue where when i check for a particular...

Batch output file without expanding variables

windows,batch-file
Let's say I have something that is: echo %cd% echo %~f0 and I want to output that to foo.bat: echo echo %cd% > foo.bat echo echo %~f0 >> foo.bat this wouldn't work, though, since the variables would be expanded. I could do: echo echo %%cd%% > foo.bat to fix the...

bat file “cannot find file to install”

batch-file
I have a little script that creates a list from a folder and allows you to select one file to install on android. This is the code: ECHO. setlocal enabledelayedexpansion set count=0 set "choice_options_app=" for /F "delims=" %%A in ('dir /a:-d /b C:\src\release\android\') do ( set /a count+=1 set options[!count!]=%%A...

Reorder file name in folder with batch script

batch-file
I have many files that I would like to reorder the name of. Currently the file names read as XXX-YYYYY-ZZZ-A1B2C3 I would like to reorder A1B2C3 to ABC123. XXX-YYYYY-ZZZ-ABC123 The XYZ portion of the string will be variable lengths for each file, the A1B2C3 will always be at the end...

How to join output of two commands in one line?

windows,batch-file,command
For example, following commands (in Windows 7): date/t>>t.txt time/t>>t.txt create following lines in t.txt: Fri 06/12/2015 01:37 PM Is it possible to join output of two commands (see above) in one line (see below)? Fri 06/12/2015 01:37 PM The above mentioned goal can be reached by command: echo %date% %time%...

How to check and correct user input when he omit the extension .exe to kill the process?

batch-file,cmd
I have this batch to kill some process typed of course by the user and it works 5/5 when the user for example typed Calc.exe with the extension, but my issue now is to improve this batch in order to add automatically with this program if the user has omitted...

Batch : Copy files changed on a specified date only

date,batch-file
Using batch script, I want to copy files to a folder using a specific date. I don't want to copy files after the specified date, I just want the files where modification date is exactly the specified date. I used the XCOPY but the /D parameter copy files on AND...

searching a specific word from a list of words in batch file

batch-file,cmd,scripting
I have a %list% variable which has words (see the code) and I want to search a word which ends with letter 'Y' (ignoring the case-sensitive) and which starts with the last letter of user's input. User input would be any valid word. Once I find that specific word then...

ffmpeg/batch file: input format stays in output file name

batch-file,ffmpeg,aac,m4a
I created this batch file to put all aac files in one directory into an m4a container. The command works so far, but every new file generated has the format of the input file in the output files name. For example: test(.aac) is in an m4a container but is NAMED...

How do you load information from a .txt file in batch?

batch-file,save,load
So I have been doing some small batch programs lately but I can't manage to make the batch file load information. This is how i would do it. :load_game ) set /p something= ) > something.txt In the txt file: something_is_awesome That is it^^ If i remember it right that...

How can I get a one liner xcopy command to run in vbscript?

windows,batch-file,vbscript
I have an xcopy that cannot run correctly in a .bat (batch) file because of some Norwegian characters. The line is: xcopy /I /V /H /R /C /Y /K /O /X "G:\P - cad_files\Drawings\163997 Ø1000XØ90 T7-8-9.PDF" "F:\CAD\P - cad_files\Drawings\163997 Ø1000XØ90 T7-8-9.PDF" If I run it from a batch file it...

As only show the words found in the findstr

batch-file,findstr
How do I display only the words found in the search instead of displaying the lines? My code: Findstr /li /G:"List.txt" "File.txt">"Result.TxT" List: Disc Music Song Album Result: DISC1312we7das67da 13dsdsa67dsahdsa7aMUSIC dsadsdfdsaSONG1223234235 The desired result: Disc Music Song ...

Batch file rename output folder

batch-file
So I have the following code to overlay a logo image over some videos. Its working great, the only problem I have is since my logo has the naming like "0001.logo.png", the output rar file doesnt set the right file extension, it sets the "myFolder_0001.logo" extension. Is it possible to...

String parsing with batch scripting

windows,string,parsing,batch-file,xml-parsing
I have a file called pictures.xml and it contains some pictures information like: <ResourcePicture Name="a.jpg"> <GeneratedPicture Name="b.jpg"/> <GeneratedPicture Name="c.jpg"/> </ResourcePicture> <ResourcePicture Name="z1.jpg"> <GeneratedPicture Name="z2.jpg"/> <GeneratedPicture Name="z3.jpg"/> <GeneratedPicture Name="z4.jpg"/> </ResourcePicture> What I want do do is to get each line in for loop and print the names of the pictures. Sample...