errorlevel

Redirecting command-line output to keep error messages from showing in the command window

家住魔仙堡 提交于 2019-12-04 02:18:06
问题 I'm testing the existence of a folder, and, depending on its existence, I want to run different commands: DIR %MYDIR%\tmp > test.txt IF ERRORLEVEL 1 ( echo/FOLDER DOES NOT EXIST ) else ( echo/FOLDER EXISTS ) The problem is that if the folder doesn't exist I'm getting this error in addition to the standard output: The system cannot find the file specified. I'd like to display the correct output without getting the error. 回答1: How about this: DIR %MYDIR%\tmp > nul 2>&1 "> nul" means to redirect

get return code from plink?

浪子不回头ぞ 提交于 2019-12-04 01:59:08
In a DOS batch script, I'm running a single command on a remote (also windows) computer using plink. Formerly, this command was only run on the local machine, and was relying on the return code to determine success. Is there a way to easily get this information back through plink? That's not possible with plink . The current consensus is to have the remote script echo its exit code to a log file, then use pscp to transfer the log file to the local machine. See http://fixunix.com/ssh/74235-errorlevel-capturing-plink.html . with plink 0.66 C:\Code>echo Y | "C:\Program Files (x86)\PuTTY\plink.exe

How to use the return code of the first program in a pipe command line

泄露秘密 提交于 2019-12-03 14:17:41
I'm writing a simple program that parses the output from a compiler and reformats any error messages so that the IDE we use (visual studio) can parse them. We use nmake to build, and it will call the compiler using a command line like this: cc166.exe SOME_FLAGS_HERE MyCFile.c 2>&1 | TaskingVXToVisualReformat.exe Now the problem is that the return code of the compiler, cc166 , is not fed back to nmake . Only the return code of my reformatter is used which means that if I return zero from the reformat program, nmake will continue to the build instead of aborting. How can I feed back the return

PostBuild Event fails in Visual Studio after SignTool.exe error

半腔热情 提交于 2019-12-03 09:00:41
问题 We have a project in Visual Studio 2010 that runs a batch file in the post-build event. That batch calls to signtool.exe from Microsoft SDK to sign and timestamp the binary. Timestamp servers (we use http://timestamp.verisign.com/scripts/timstamp.dll), however, tend to be unreliable for some reason, failing sometimes. This caused build to fail. We implemented a more advanced batch script then (based on this code), splitting signing and timestamping, and allowing to retry the timestamp

PostBuild Event fails in Visual Studio after SignTool.exe error

空扰寡人 提交于 2019-12-03 00:31:39
We have a project in Visual Studio 2010 that runs a batch file in the post-build event. That batch calls to signtool.exe from Microsoft SDK to sign and timestamp the binary. Timestamp servers (we use http://timestamp.verisign.com/scripts/timstamp.dll ), however, tend to be unreliable for some reason, failing sometimes. This caused build to fail. We implemented a more advanced batch script then (based on this code), splitting signing and timestamping, and allowing to retry the timestamp operation, if it failed. Here is a simplified version of the batch script (signfile.bat): @echo off REM sign

Redirecting command-line output to keep error messages from showing in the command window

◇◆丶佛笑我妖孽 提交于 2019-12-01 12:09:36
I'm testing the existence of a folder, and, depending on its existence, I want to run different commands: DIR %MYDIR%\tmp > test.txt IF ERRORLEVEL 1 ( echo/FOLDER DOES NOT EXIST ) else ( echo/FOLDER EXISTS ) The problem is that if the folder doesn't exist I'm getting this error in addition to the standard output: The system cannot find the file specified. I'd like to display the correct output without getting the error. How about this: DIR %MYDIR%\tmp > nul 2>&1 "> nul" means to redirect standard output to the file nul (the bit bucket). "2>" is used to redirect standard error (descriptor 2).

Killing a process in Batch and reporting on success

耗尽温柔 提交于 2019-11-30 14:56:05
i have the following batch file, which terminates the iTunes program so, that if i connect my iPod, it's not going to sync it. (I know you can set this up in iTunes.) @echo off :kill cls taskkill /F /IM itunes.exe >nul if %errorlevel%==1 { echo iTunes not found. } else { echo iTunes is killed. } goto kill However, the >nul does not respond to the command; so it just gives the default command text. So yeah, what i want to do: If iTunes is not found, as given by the command, it should display iTunes not found If it is found and terminated, iTunes is killed Help? the errorlevel's don't work, this

Batch file 'choice' command's errorlevel returns 0

大憨熊 提交于 2019-11-30 14:20:47
I'm trying to create a batch file that performs different 'choice' command based on the version of Windows being executed on. The choice command's syntax is different between Windows 7 and Windows XP. Choice command returns a 1 for Y and 2 for N. The following command returns the correct error level: Windows 7: choice /t 5 /d Y /m "Do you want to automatically shutdown the computer afterwards " echo %errorlevel% if '%errorlevel%'=='1' set Shutdown=T if '%errorlevel%'=='2' set Shutdown=F Windows XP: choice /t:Y,5 "Do you want to automatically shutdown the computer afterwards " echo %ERRORLEVEL%

Killing a process in Batch and reporting on success

我与影子孤独终老i 提交于 2019-11-29 22:35:15
问题 i have the following batch file, which terminates the iTunes program so, that if i connect my iPod, it's not going to sync it. (I know you can set this up in iTunes.) @echo off :kill cls taskkill /F /IM itunes.exe >nul if %errorlevel%==1 { echo iTunes not found. } else { echo iTunes is killed. } goto kill However, the >nul does not respond to the command; so it just gives the default command text. So yeah, what i want to do: If iTunes is not found, as given by the command, it should display

System.exit(num) or throw a RuntimeException from main?

旧时模样 提交于 2019-11-29 09:14:13
I've got a single threaded app that should set the DOS errorlevel to something non-zero if there is a problem. Is it better to throw a RuntimeException, or to use System.exit(nonzero)? I don't need the stack trace, and I don't expect this app to be extended/reused. What are the differences between these two options? Don't throw an exception unless you really have an exceptional condition. System.exit(int) is there for precisely this reason. Use it. EDIT: I think I may have misread your question. I thought you were asking, when you want to exit the JVM normally but signal that something did not