What return values do the cmd.exe commands return?

I have only begun to use PowerShell which I find way to complex at this time so for me the cmd.exe batch file does much of what I need, but I tried to find a list of the errorlevels returned by each of the commands but I couldn't find it. I found descriptions
of the command here:
http://technet.microsoft.com/en-us/library/cc772390(v=ws.10).aspx but they don't give return values.
In particular I was looking for the return value of the find command. I assumed 0 meant found, and 1 meant not-found, but nothing told me that. It could be that 0 only meant the find did not return an error, irrelevant to the finding something or not, when
1 might mean find exited prematurely (such as when using find in a protected directory). I since found that 0 means found and 1 means not found, but what if I needed to plan for how to handle exit codes other than those two?
I'm looking with respect to W7 Pro for return values for all the commands, not just find. I did a search in this forum and "on the net" before I submitted this question, but with more than 108K results just in this forum,
I found I didn't have the time to look through them all. "On the net" gave me some results for specific commands, but not all of them.
So, can someone point me to a list of cmd.exe command return codes for W7?

Hi,
Some discussion about return value:
Windows PowerShell Exit Codes
http://blogs.msdn.com/b/powershell/archive/2006/10/14/windows-powershell-exit-codes.aspx
As you can see, it indeed depends who set it.
Alex Zhao
TechNet Community Support

Similar Messages

  • I ran the Adobe installer for CC desktop and it failed.  Error: 50   What happened?  Now the Run.exe file is gone.

    I ran the Adobe installer for CC desktop and it failed.  Error: 50   What happened?  Now the Run.exe file is gone.

    Hi,
    Please refer to the thread below where this issue has been discussed:
    Error code 50
    Regards,
    Sheena

  • How to ensure that giving the firefox.exe command in run dialog box in Windows opens up a specific firefox Profile?

    I have a firefox profile with certain proxy settings set. When I type firefox.exe in the run dialog Box in windows it opens up the default profile. I have a firefox shortcut specified with the command line args -P "profilename". I want this to be used as it will force the custom profile. Is there an environment variable that i can set for this?

    You can set the default profile to use in the Profile Manager to be used when no profile is specified and otherwise use desktop shortcuts with a profile specified (-P "profile").<br />
    There is also a "Don't ask at startup" check box in the PM window.
    *http://kb.mozillazine.org/Profile_Manager

  • Requirement is to run CMD.EXE under the Local System Account. So that we can map a network drive to be used by a windows service, which will be created by command: - net use z: \\servername\sharedfolder /persistent:yes

    Environment:
    OS:  Windows 7 32/64 bit, Windows 2008 Server 64
    bit/ Windows 2012 Server 64 bit
    Priority:
    - Critical
    Requirement: - Since
    the Windows Service is running under the Local System Account, we would like to emulate this same behaviour.
    Basically, we would like to run CMD.EXE under the Local System Account. So that we can map a network drive to be used by a service using following
    command
    net use z: \\servername\sharedfolder /persistent:yes.
    Already Attempt:
    We tried to launch the CMD.exe using the DOS Task Scheduler AT command.  Here’s a sample command:
    AT 10:36 /interactive cmd.exe
    But I received a warning that “due
    to security enhancements, this task will run at the time excepted but not interactively.”
    It turns out that this approach will work for XP, 2000 and Server 2003 but due to session isolation
    Interactive services no longer work on Windows 7, Windows Server 2008 and above.
      2.  We
    tried to create a secondary Windows Service via the Service Control (sc.exe) which merely launches CMD.exe.
    <Drive>:\sc create RunCMDAsLSA binpath= "cmd" type=own type=interact <Drive>:\sc
    start RunCMDAsLSA
    In this case the service fails to start and results it the following error message:
    FAILED 1053: The service did not respond to the start or control request in a timely fashion.
      3. One
    suggestion, we found to launch CMD.exe via a Scheduled Task, but
    it is not giving any option to launch CMD.exe in interactive mode; so that I can map network drive using net command.
      4. I read an article, which
    demonstrates the use of PSTools from SysInternals. I launched the command line and executed following command
    psexec -i -s cmd.exe
    PSTools worked fine, but It seems that in scope of Sysinternals Software License
    Terms. You may not "use the software for commercial software hosting services."
    Application will deploy on client, which will be like commercial,
    so we are not able to use PSTools.         
    Kindly assist us for achieving the requirement. We have tried all the ways, but nothing is working for us. Kindly suggest.
    I will be really thankful.

    Hi Sir,
    Nothing worked from above for us. You can see our remarks on posted query.
    That’s why, we posted on forum.
    And there will not be any vulnerability, because, if we will use "net
    use ..."
    in network domain; definitely,
    we will provide username and password of mapped drive system.
    And, that system, itself is given by client; so that, there must not be any vulnerability; they are ready to provide user name and password.
    We need a way; by which we can complete the requirement. Kindly assist.
    Regards,
    S. P. Singh

  • Many dead cmd.exe on Windows 2008 R2 Oracle 11.2.0.2 RAC Installation

    After successful installation of a two node Oracle RAC 11.2 on Windows 2008 R2 we investigate a daily growing number of cmd.exe all running the following statement:
    *C:\Windows\system32\cmd.exe  /K D:\oracle\cluster\11.2.0\grid\bin\cluvfy  comp health -_format*
    Does anyone know the originator/source of this "cluvfy" command?
    Maybe the Grid Control Agent?
    We think, that the "/K" option is the problem, i.e. the reason while the cmd.exe will not terminate.
    When we run the "cluvfy" manually everythings results successfully.
    Thanks for your reply.
    Michael

    I have done the same and get the run around from the support tech when I ask for clarification. Even asked duty manager for assistance and was sent right back to the support tech that I could not get conclusive answers to my question from the first time. Seems he is telling me that he opened a new bug up for my answer but the description of the problem is not the same so how can I believe him. He wants me to apply patch 12 but I thought the later patches set are supposed to contain previous patches, so why not apply patch 14 or newest. Seems none of the patches show that they solve the Windows Heap Issue for 11.2.0.3. Even the bug note says it will be fixed in 11.2.0.4. Just one more reason we are planning (although against my better judgement) to move away from oracle.

  • Using the javaw.exe

    hello,
    i'm just new here. may i ask how to use the "javaw.exe" command in the windows98 file types thingy? so that i can run the classes by doubble cliking them. or should i just put them into a .jar file? (another story)
    thank you
    kirby

    to make your program auto-exec you need to make a manifest file that points to Main Class : yourMain, and then put all class and manifest files into a jar.
    If your windows does not open the jar after double clickn and ask what program you want to use , then you browse to the javaw.

  • Controlling "CMD.EXE" via Process - Never ends?

    I'm trying to write a Java program that parses a text file & executes various command promt commands (I'm trying to keep it platform independant, because I know Lin/Un/nix users who would find this userful as well). I found a small tutorial on the web which gave an example of:
    Process p = Runtime.getRuntime().exec("<YOUR COMMAND HERE>");
    BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
    BufferedWriter stdOutput = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
    BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getInputStream()));
    Now; I have inserted "cmd.exe" for <YOUR COMMAND HERE>. If I write a command out to stdOutput, the first command executes, but not subsequent ones. Small segment looks like:
    while (line != null) {
    stdOutput.write("mkdir \"" + new_folder + "\"\n");
    stdOutput.flush();
    line = file_reader.readLine();
    This is an abridged version of my ode, but thats the problem. I get the first folder created, the process never terminates and I've tried emptying out the stdInput & stdErr bufferes, but it still won't execute subsequent commands issued to stdOutput.
    Can someone help me? I'd rather not write this all to a .BAT/.sh file :(

    I am quite perplexed now! I have just tried the following code on my PC, and have ended up with the most annoying two folders under my C:\ drive!
    import java.io.*;
    public class Cmd {
        public static void main(String[] args) {
            try {
                Process p = Runtime.getRuntime().exec("cmd.exe");
                BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
                BufferedWriter stdOutput = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
                BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getInputStream()));
    //            System.out.println(stdInput.readLine());
    //            System.out.println(stdInput.readLine());
    //            System.out.println(stdInput.readLine());
                stdOutput.write("mkdir \"c:\\folder1\"\n");
                stdOutput.flush();
    //            System.out.println(stdInput.readLine());
                stdOutput.write("mkdir \"c:\\folder2\"\n");
                stdOutput.flush();
    //            System.out.println(stdInput.readLine());
            } catch (IOException e) {
                e.printStackTrace();
    Perlexion over! Since you had your code in a loop I tried the same. I saw that in a loop creating 10 folders, the code created only two. See below the code that fixed this problem:
    import java.io.*;
    public class Cmd {
        public static void main(String[] args) {
            try {
                Process p = Runtime.getRuntime().exec("cmd.exe");
                BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
                BufferedWriter stdOutput = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
                BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getInputStream()));
                System.out.println(stdInput.readLine());
                System.out.println(stdInput.readLine());
                System.out.println(stdInput.readLine());
                stdOutput.write("mkdir \"c:\\folder1\"\n");
                stdOutput.flush();
                System.out.println(stdInput.readLine());
                stdOutput.write("mkdir \"c:\\folder2\"\n");
                stdOutput.flush();
                System.out.println(stdInput.readLine());
            } catch (IOException e) {
                e.printStackTrace();
    }Commenting out different combinations of System.outs gives different results.
    In summary: it is important that you match the correct number of output lines from the CMD.EXE output stream with readLines.
    I didn't like how the wording came out, but you get the gist.
    HTH,
    Manuel Amago.

  • Unable to run cmd.exe in hosted web application?

    Hi
    I have to execute a cmd.exe in web application to merge a file.My code work fine on my dev environment. But on hosting the
    application on server unable to run the cmd.exe . Below is the code.
     ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe");
                        processStartInfo.RedirectStandardInput = true;
                        processStartInfo.RedirectStandardOutput = true;
                        processStartInfo.UseShellExecute = false;
                        Process process = Process.Start(processStartInfo);
                        if (process != null)
                            process.StandardInput.WriteLine("c:");
                            process.StandardInput.WriteLine("xcopy " + srcfilename + " " + destfilename + "
    /a /m /d /s /e /v");
                            // process.StandardInput.WriteLine("a");
                            process.StandardInput.Close(); // line added to stop process from hanging on ReadToEnd()
                            string outputString = process.StandardOutput.ReadToEnd();
                            process.Close();
                            // process.Kill();                   
    Pawan

    What is the hosting you are using on azure? Hosted your application as Azure web site or cloud service?
    If it is a azure cloud service - you will either need to define the start up tasks to do the same or need to run your azure roles in elevated context.
    Read more - https://msdn.microsoft.com/en-us/library/azure/gg456327.aspx
    https://msdn.microsoft.com/en-us/library/gg557553.aspx#Runtime
    Bhushan | Blog |
    LinkedIn | Twitter

  • CMD.EXE DIR command returns incorrect files for wildcard

    So, I'm at a Windows 7 command prompt.  The current folder has both old and new Excel files in it.  That is, some have a file extension of ".xls", while others are ".xlsx".  I enter the following command:
    dir *.xls
    This is returning all files in the folder. 
    Anybody with a knowldege of regular expression language would say that the ".xlsx" files should be excluded, since the "*" is to the left of the ".", and should only apply to the file name, not to the file extension. 
    If I wanted to return all Excel files, I should have to specify "*.xls*".
    Am I missing something here?  Is this not a bug in the Windows 7 cmd.exe?   Seems like a pretty dangerous one, since it could lead to the unwanted deletion of files.
    - Mark Z.

    This is because 8.3 compatible filenames (aka short filenames)  are created for your files. By default, creation of short names is enabled. Use dir /x to verify.
    -- pa

  • What command can be run from the cmd to inquire about the language layout that is used right now?

    I have windows 7 32bit platform. Is there any command that can be run from the command line just to inquire about the language bar that is currently in use? Suppose I have English keyboard on my machine but I am switching between 3 languages when I write
    my documents (e.g. English, German, Spanish). I want to know if there is any way to tell what language layout that is in current use as seen in the language bar. This question is not about how to change language layout from the command line -- just to know
    what layout. For example, the command can return some sort of string to indicate which layout is currently in use: "english", "german", "spanish", and so on.
    My ultimate goal from this question is to pass this output into an external editor that will hopefully change font based on the input language? Any help to achieve this goal will be much appreciated.
    Or put differently, what is the best way to tell an external editor like Emacs about the current language layout that is in current use?

    For the current input language you can try using
    reg query "HKCU\Keyboard Layout\Preload" /v 1
    The return value includes an eight digit hex value. The first four digits indicate either default layout for the language (all zeros) or a variation (non-zero). The last four digits are the locale id - see:
    http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx
    From this table, you can see in the example above my input language is English - Australia. 
    For the keyboard layout you could try
    WMIC Path Win32_Keyboard Get Layout
    0409 is an English - US keyboard.
    For a few other ideas/methods try reading
    http://p0w3rsh3ll.wordpress.com/2013/06/07/about-keyboard-layouts/

  • How can I pass a value to the command prompt?

    I was wondering how can I pass a value to the command prompt with Windows and Linux? I'm more interested in Linux's system than Windows though. Is there a way to return info from the command prompt?

    Here is a snippet from http://mindprod.com/jglossexec.html that explains how in detail.
    Runtime.getRuntime().exec("myprog.exe") will spawn an external process that runs in parallel with the Java execution. In Windows 95/98/ME/NT/2000/XP, you must use an explicit *.exe or *.com extension on the parameter. It is also best to fully qualify those names so that the system executable search path is irrelevant, and so you don't pick up some stray program off the path with the same name.
    To run a *.BAT, *.CMD, *.html *.BTM or URL you must invoke the command processor with these as a parameter. These extensions are not first class executables in Windows. They are input data for the command processor. You must also invoke the command processor when you want to use the < > | piping options, Here's how, presuming you are not interested in looking at the output:
    Runtime.getRuntime( ).exec ("command.com /E:1900 /C MyBat.bat" );
    Runtime.getRuntime( ).exec ("cmd.exe /E:1900 /C MyCmd.cmd" );
    Runtime.getRuntime( ).exec ("C:\\4DOS601\\4DOS.COM /E:1900 /C MyBtm.btm" );
    Runtime.getRuntime( ).exec ("D:\\4NT301\\4NT.EXE /E:1900 /C MyBtm.btm" );
    There are also overloaded forms of exec(),
    Runtime.getRuntime( ).exec ("command.com /E:1900 /C MyBat.bat", null);
    Runtime.getRuntime( ).exec ("command.com /E:1900 /C MyBat.bat", null, "C:\\SomeDirectory");
    The second argument can be a String [], and can be used to set environment variables. In the second case, "C:\\SomeDirectory" specifies a directory for the process to start in. If, for instance, your process saves files to disk, then this form allows you to specify which directory they will be saved in.
    Windows and NT will let you feed a URL string to the command processor and it will find a browser, launch the browser, and render the page, e.g.
    Runtime.getRuntime( ).exec ("command.com http://mindprod.com/projects.html" );
    Another lower level approach that does not require extension associations to be quite as well set up is:
    Runtime.getRuntime( ).exec ("rundll32 url.dll,FileProtocolHandler http://mindprod.com/projects.html" );
    Note that a URL is not the same thing as a file name. You can point your browser at a local file with something like this: file://localhost/E:/mindprod/jgloss.html or file:///E|/mindprod/jgloss.html.
    Composing just the right platform-specific command to launch browser and feed it a URL to display can be frustrating. You can use the BrowserLauncher package to do that for you.
    Note that
    rundll32.exe url.dll,FileProtocolHandler file:///E|/mindprod/jgloss.html
    won't work on the command line because | is reserved as the piping operator, though it will work as an exec parameter passed directly to the rundll32.exe executable.
    With explicit extensions and appropriately set up associations in Windows 95/98/ME/NT/2000/XP you can often bypass the command processor and invoke the file directly, even *.bat.
    Similarly, for Unix/Linux you must spawn the program that can process the script, e.g. bash. However, you can run scripts directly with exec if you do two things:
    Start the script with #!bash or whatever the interpreter's name is.
    Mark the script file itself with the executable attribute.
    Alternatively start the script interpreter, e.g.
    Runtime.getRuntime( ).exec (new String[]{"/bin/sh", "-c", "echo $SHELL"}";

  • WINE err:"wine cmd.exe /c echo '%ProgramFiles%' returned empty string"

    So as the tittle states WINE is throiwng this error:
    wine cmd.exe /c echo '%ProgramFiles%' returned empty string
    As for what might have caused it? probably the last system update which was performed a few days ago, my old prefix works fine but I have a habit of creating new prefixes for troublesome applications, or applications I am unsure of whether they will cause trouble or not.
    Hence I created a new prefix using:
    export WINEARCH=win32
    export WINEPREFIX=~/.problematic
    winecfg
    As for how wine is run, it's run as a normal, unprivileged, user.
    Oh and I also tried generating yet another prefix like this:
    $ WINEARCH=win32 WINEPREFIX=~/.problematic-new winetricks steam
    Executing w_do_call steam
    wine cmd.exe /c echo '%ProgramFiles%' returned empty string
    Didn't work either.
    I'm at loss, any suggestion on how to fix it?
    Last edited by CubeGod (2014-06-29 15:48:05)

    $ WINEARCH=win32 WINEPREFIX=~/testprefix notepad.exe
    bash: notepad.exe: command not found
    So obviously I need to correct the command
    $ WINEARCH=win32 WINEPREFIX=~/testprefix wine notepad.exe
    wine: created the configuration directory '/home/shiina/testprefix'
    err:module:load_builtin_dll failed to load .so lib for builtin L"winemp3.acm": libmpg123.so.0: cannot open shared object file: No such file or directory
    fixme:ntdll:NtLockFile I/O completion on lock not implemented yet
    err:mscoree:LoadLibraryShim error reading registry key for installroot
    err:mscoree:LoadLibraryShim error reading registry key for installroot
    err:mscoree:LoadLibraryShim error reading registry key for installroot
    err:mscoree:LoadLibraryShim error reading registry key for installroot
    fixme:ntdll:NtLockFile I/O completion on lock not implemented yet
    fixme:iphlpapi:NotifyAddrChange (Handle 0xece880, overlapped 0xece88c): stub
    wine: configuration in '/home/shiina/testprefix' has been updated.
    Wine cannot find the ncurses library (libncursesw.so.5).
    why is ncurses a dependency anyway? besides, wicd-curses works so this shouldn't be the case.
    Anyway, trying winetricks in the same prefix
    $ WINEARCH=win32 WINEPREFIX=~/testprefix winetricks steam
    Executing w_do_call steam
    wine cmd.exe /c echo '%ProgramFiles%' returned empty string
    Anyway, I expected notepad to work since it resides in %WINDOWS% not %ProgramFiles%
    Is there any registry key I can set for this? all my google searching says this can cause with a mismatch of wine versions but why would that happen?
    Either way checking wine --version outputs wine-1.7.20 which is the same as it was pre-update (when it still worked).

  • Checking existence of command in cmd.exe

    I want to run somone from cmd.exe using some procedure, for example WEBUTIL_HOST.HOST ('cmd / c start iexplore' | | url)
    Can I somehow check before executing, that command exists and that it will be execute?
    Edited by: Ihavoker on 04.02.2011 16:42

    InoL wrote:
    HOST doesn't return an error when the OS command returns an error. HOST only fails when the HOST call itself fails. So checking form_failure is usually not what you want.
    However, in your case you should try:
    HOST ('cmd / c start ' | | url);
    If you just start an URL, Windows will automatically look for the default browser.I understand, it might seem strange.
    Unfortunately, it is necessary to open a web page only IE. However, the browser by default does not necessarily IE. And the forms should check, the IE installed. Ie Command HOST ('cmd / c iexplore' | | url); executed. Just not sure that IE is installed in the default directory.
    That is a problem... :(
    Edited by: Ihavoker on 07.02.2011 12:16

  • How to send a command from a vc++.exe to LABVIEW.exe in order to control the button on the LABVIEW.exe

    Hello, everyone. Using VC++, I have gotten the handle of a *.exe(built by Labview), but I cannot get the button handle. I want to get the button handle and post the message to control the button. How can I do that? When I use the SPY++, the *.exe(built by Labview) have not any child windows which is very different from the *.exe(built by VC++). In SPY++, what is the LVDChild class? How can I send the message to control the button on *.exe(built by Labview)???
    That is  to send a command from a vc++.exe to LABVIEW.exe in order to control the button on the LABVIEW.exe. How can I get it ?
    Thank you!

    hummingbird wrote:
    Thank you! But I dont kown how to use vi server to raise a value signalling event. Can we put vi server into the vc program? Can you give me some more information or some examples, hehe!
    hummingbird
    Checkout the LabVIEW ActiveX server interface in the User Manual in Chapter 20, Windows Connectivity and the VI Server Reference in Chapter 17, Programmatically Controlling VIs.
    There is a sample for Visual Basic under examples/comm/VBtoLV.frm, which should be quite simple to translate to Visual C as long as you can figure out the basics of ActiveX programming in VC (I have never done anything with ActiveX in VC). For those basics I would recommend some text book or MSDN.
    Rolf Kalbermatter 
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • What is wrong with the idl code generated by packager.exe?

    Hello everybody,
    I am trying to figure out what is wrong with the idl code generated by packager.exe. In the evaluation for the bug posted at http://developer.java.sun.com/developer/bugParade/bugs/4964563.html it says that the IDispatch interface is not exposed correctly and thus early binding of java objects is not possible using the current activex bridge implementation.
    As I am no idl expert I have no idea what that means. However, I managed to dig out the idl code generated by packager.exe for the following example bean:
    package test;
    public class MyBean
         protected int value;
         public MyBean()
         public void setMyValue(int _value)
              value = _value;
         public int getMyValue()
              return value;
         public MyBean getSelfReference()
              return this;
    }The corresponding idl code generated by packager.exe is
    uuid(81B0BF63-2A55-11D8-A73E-000475EBF021),
    version(1.0)
    library MyBean
    importlib("Stdole2.tlb");
    dispinterface MyBeanSource;
    dispinterface MyBeanDispatch;
    uuid(81B0BF64-2A55-11D8-A73E-000475EBF021),
    version(1.0)
    dispinterface MyBeanSource {
    properties:
    methods:
    uuid(81B0BF65-2A55-11D8-A73E-000475EBF021),
    version(1.0)
    dispinterface MyBeanDispatch {
    properties:
    [id(4097)]
    int myValue;
    methods:
    [id(32768)]
    VARIANT_BOOL equals(IDispatch* arg0);
    [id(32769)]
    IDispatch* getClass();
    [id(32770)]
    int getMyValue();
    [id(32771)]
    IDispatch* getSelfReference();
    [id(32772)]
    int hashCode();
    [id(32773)]
    void notify();
    [id(32774)]
    void notifyAll();
    [id(32775)]
    void setMyValue(int arg0);
    [id(32776)]
    BSTR toString();
    [id(32779)]
    VARIANT wait([optional] VARIANT var0, [optional] VARIANT var1);
    uuid(81B0BF62-2A55-11D8-A73E-000475EBF021),
    version(1.0)
    coclass MyBean {
    [default, source] dispinterface MyBeanSource;
    [default] dispinterface MyBeanDispatch;
    };Does anyone know what is wrong with this code and maybe how to fix the idl code? Generating the dll should then be easy (I already tried several variations of the idl code but as my idl knowledge is limited it didn't really do what I wanted).

    Then the question is why it does work with visual controls (even if you set them to non-visible)?

Maybe you are looking for