batch-file

For loop and multiple labels in batch script

99封情书 提交于 2020-02-02 18:56:56
问题 I am trying to implement a use case: Where I want to refresh series of reports , with each report when failed should attempt to run again and then send out a email notification. I have below issues which needs help: In the below code if my first command (cmd[0]) is success , I don't want to execute :erroremail section , but just go run the second command (cmd[1]) instead from the loop. How can I achieve this? Basically when my for loop completes (when all my commands are executed) I don't

nested For loop in batch file error: Do was unexpected at this time

為{幸葍}努か 提交于 2020-02-02 16:07:30
问题 I am new to writing batch files. I am trying to do the following . Read line by line from file called list.txt which has two tokens which are space seperated and in the next for loop i am tokenizing and sending these tokens as parameters to another script. FOR /F %%i IN (C:\list.txt) DO FOR /F "tokens=1,2 delims= " %%A IN (%%i) DO winscp.com /script=C:\myscript1.txt /parameter %%A C:\%%B But I am getting the following error. Do was un expected at this time. Can some one explain what am I

Batch Script - Count instances of a character in a file

痴心易碎 提交于 2020-02-02 11:37:05
问题 Using a batch script (.bat file) in windows xp, how would I go about reading a text file and finding how many instances of a character exists? For example, I have a string with the following: ""OIJEFJ"JOIEJKAJF"""LKAJFKLJEIJ""JKLFJALKJF"LKJLKFA""""LKJKLFJLKADJF I want it to count how many " there are in the file and return the count. 回答1: Let's start counting the characters in a line. First the slow and clear method: set i=-1 set n=0 :nextChar set /A i+=1 set c=!theLine:~%i%,1! if "!c!" == ""

How can I see if a string is four letters long? – Windows Batch

浪子不回头ぞ 提交于 2020-02-02 10:28:09
问题 So I'm working on a Windows Batch script and I want to know if an input string (the name of a file) is exactly four letters long. I want to do it with regular expressions or string matching. I tried the following but it didn't work... for /R "%windir%\system32" %%f in (*) do ( set filename=%%~nf if not "!filename!"=="!filename:[a-z][a-z][a-z][a-z]=!" ( echo %%~nf ) ) So my code loops through all the files in \system32. The files like mode.com should be echoed, but it's not the case. 回答1: This

Get IP address from IPConfig, use later in code, or save [closed]

删除回忆录丶 提交于 2020-02-02 07:51:01
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . Is it possible to run a code that searches IPConfig for the IP address then saves that to a text document or enters it into the prompt? I want to be able

Get IP address from IPConfig, use later in code, or save [closed]

孤者浪人 提交于 2020-02-02 07:48:14
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . Is it possible to run a code that searches IPConfig for the IP address then saves that to a text document or enters it into the prompt? I want to be able

Get IP address from IPConfig, use later in code, or save [closed]

跟風遠走 提交于 2020-02-02 07:47:29
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . Is it possible to run a code that searches IPConfig for the IP address then saves that to a text document or enters it into the prompt? I want to be able

Propagating exit code from exec'd batch file back to ant

99封情书 提交于 2020-02-02 03:05:10
问题 I need to call sbt from ant. I'm doing this with the "exec" task as follows: <target name="publish-jar"> <exec executable="sbt.bat" failonerror="true"> <arg value="publish"/> </exec> </target> I need the ant task to "fail" if the sbt task fails, which is why failonerror="true" is being used. However, this does not work. When the sbt task fails, ant does not report a failed build. This looks like the problem discussed here: Ant exec resultproperty is not working. The suggested workaround is to

Using psexec.exe in jenkins, handle is invalid

送分小仙女□ 提交于 2020-02-02 02:43:32
问题 I am using Jenkins on a Windows7 system. I would like to use it to execute a batch script on a remote Windows system. The batch script will be used to flash a development board and run some tests. I came across psexec.exe. That works well through a command prompt window--I can connect and run the script without any issues, but when I try to have Jenkins do it, I get the following output: PsExec v2.11 - Execute processes remotely Copyright (C) 2001-2014 Mark Russinovich Sysinternals - www

Using psexec.exe in jenkins, handle is invalid

删除回忆录丶 提交于 2020-02-02 02:43:09
问题 I am using Jenkins on a Windows7 system. I would like to use it to execute a batch script on a remote Windows system. The batch script will be used to flash a development board and run some tests. I came across psexec.exe. That works well through a command prompt window--I can connect and run the script without any issues, but when I try to have Jenkins do it, I get the following output: PsExec v2.11 - Execute processes remotely Copyright (C) 2001-2014 Mark Russinovich Sysinternals - www