batch-file

escape character in IF

妖精的绣舞 提交于 2020-01-05 05:35:53
问题 i tried this in different variations (like setlocal EnableDelayedExpansion)- but nothing works: echo off IF "%1"=="Debug^|Win32" set servicesConfig=Win2008.Debug echo Incorrect parametr %servicesConfig% pause > nul 回答1: As quotes escapes special characters you compare the content of %1 with Debug^|Win32 (including the caret). In your case you should use this @echo off IF "%~1"=="Debug|Win32" ( echo It's ok set servicesConfig=Win2008.Debug ) ELSE ( echo Unknown in "%~1" ) You can call it with

Is it possible to suppress MessageBox when running a specific command?

僤鯓⒐⒋嵵緔 提交于 2020-01-05 04:37:08
问题 I'm using Tortoise SVN, and TortoisePlink for remote ssh connections. From time to time TortoisePlink is displaying errors like: --------------------------- TortoisePlink Fatal Error --------------------------- Network error: Software caused connection abort --------------------------- OK --------------------------- And they appears as messagebox and needs to be clicked by end-user. I have tried to suppress messagebox by using -batch from command line, but problem still can be reproduced. For

Problems with an extra space when redirecting variables into a text file

混江龙づ霸主 提交于 2020-01-05 04:23:12
问题 When I run the following lines: set "Loc=%~dp0" echo %Loc% > C:\PLACE\LOCFILE.txt I receive the following in the LOCFILE: C:\BATCHLOC ^ Note Space I am trying to use %Loc% like this in a separate batch file: ( set /p Loc= )<C:\PLACE\LOCFILE.txt ) call "%Loc%\FILENAME.bat" But the space ruins the path, and so then the call command doesn't work. Does anyone know how to fix this, (Stop it from creating the space at the end)? 回答1: echo %Loc% > C:\PLACE\LOCFILE.txt ↑ This space is written to the

run a input parameter as command in dos batch script?

浪尽此生 提交于 2020-01-05 04:16:06
问题 How can I run a command in my dos script from an input argument ? Simplified script bla.bat: CALL %1 Call it: bla.bat "echo 'hello'" (or bla.bat "git status") Error: '"git status"' is not recognized as an internal or external command, operable program or batch file. It works if I do "CALL git status". 回答1: It looks like the problem may be that you have surrounding quotes in your input, which you'll need to stop it being broken into the different %n arguments, but try: %~1 Which will strip any

How to get the last word in the last line in a file with Windows batch script?

橙三吉。 提交于 2020-01-05 03:57:13
问题 I have a file sample.txt with the content as below. H|20170331|CIS A||A1140|GRM //header A||A1140|GRM A||A1140|GRM A||A1140|GRM A||A1140|GRM T|20170331|5 //trailer I need the last token in the last line i.e. 5 . (It's the count of the line except header trailer) . As of now, I tried below; it's giving the first token, i.e. T , but I need the last token i.e. 5 . @echo off rem for /f "skip=1 tokens=2,* delims=" %%a in (sample.txt) do set "variable=%%a" rem for /f "delims=|" %%x in (sample.txt)

Batch Script - How to get variable value using a different variable that has the variable name stored

这一生的挚爱 提交于 2020-01-05 03:54:47
问题 I'm having trouble access the value stored in the example below. I need to access the value stored in a variable, but the variable name is stored in a different variable. Please help. Example: setlocal enabledelayedexpansion set a222333password=hellopass for %%i in (%fileserver%\t*) do ( set currentfilename=%%~ni --> file name is "t222333" set currentlogin=!currentfilename:t=a! --> login is "a222333" set currentpasswd=!!currentlogin!password! --> password should be "hellopass" echo

Keeping blank lines intact when reading from one file to another

大憨熊 提交于 2020-01-05 03:36:21
问题 I am reading line by line from a properties file to another file using below code(batch file). The problem is It is removing all the blank lines from the source file. What changes I should do in order to make blank lines available to destination file? FOR /F "USEBACKQ tokens=*" %%A IN (`FIND /V "" ^<"%FILE%.SRC"`) DO ( ECHO %%A>>"%FILE%" ) 回答1: FOR /F will always skip empty lines, so you have to avoid empty lines. This can be solved with prepending the lines by a line number with findstr or

Keeping blank lines intact when reading from one file to another

大城市里の小女人 提交于 2020-01-05 03:36:09
问题 I am reading line by line from a properties file to another file using below code(batch file). The problem is It is removing all the blank lines from the source file. What changes I should do in order to make blank lines available to destination file? FOR /F "USEBACKQ tokens=*" %%A IN (`FIND /V "" ^<"%FILE%.SRC"`) DO ( ECHO %%A>>"%FILE%" ) 回答1: FOR /F will always skip empty lines, so you have to avoid empty lines. This can be solved with prepending the lines by a line number with findstr or

How to create a RAR archive with current date in archive file name?

依然范特西╮ 提交于 2020-01-05 02:27:49
问题 I have folder D:\data with lots of subfolders and files and I want to archive this folder with a batch file to a specified directory with current date added in archive file name, e.g. F:\11.08.2016_data . My command line is so far: "C:\Program Files\WinRAR\rar.exe" a -ep1 -r "data" "D:\data" This command line creates RAR archive file data.rar in folder My Documents . How can I add date and change the archiving directory? 回答1: How to build a WinRAR command line? Start WinRAR . Click in menu

Run a batch file at folder's context menu

北城以北 提交于 2020-01-05 02:18:10
问题 I'd like to run this batch file (setenv.cmd) when I right click on any folder: @echo off SET CPLUS_INCLUDE_PATH=C:\mingw32\include;C:\mingw32\lib\gcc\mingw32\4.9.2\include; SET PATH=%PATH%;C:\Archivos de programa\7-Zip;C:\Archivos de programa\WinRAR;C:\usr\bin;C:\msys\1.0\bin;C:\gtk2\bin SET PKG_CONFIG_PATH=C:\gtk2\lib\pkgconfig;C:\usr\lib\pkgconfig @echo on I setuped my registry from this page, with the "prompt here". My question is how to open the console window from the selected directory