Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a "noop"-esque exe somewhere as part of the Windows installation? I'm preparing some batch jobs and scheduled tasks, and for a couple reasons I'd like to reference an executable that does nothing -- i.e. launches with no visible window, and quits immediately.

Does such an executable exist in the usual Windows installation anywhere? or how can I come close? I do not want to have to depend on anything not already included in Windows.

share|improve this question
1  
From observation: svchost.exe doesn't open anything. –  ta.speot.is Jan 22 '12 at 12:40
    
@todda.speot.is you should include that as a full answer. –  DuckMaestro Feb 19 '12 at 8:05
1  
Did it have to be an external (executable) file? If not, then the rem command could have worked (and depending on where in the batch-file it is being used, possibly even the :: variant). –  Synetech Nov 29 '13 at 20:03

9 Answers 9

up vote 18 down vote accepted

You may use rundll32:

  • No console window
  • No side effects
  • Just 44 KB
  • No arguments required
  • Works on every recent Windows version (XP, Vista, 7), and probably on every NT-based system.
share|improve this answer
    
So why is it there? –  Nathan Feb 14 '12 at 4:04
3  
@Nathan With the appropriate arguments, it can call a function inside of a DLL –  Andrea Feb 14 '12 at 8:32
    
Right. For example, imagine a simple print.exe program that simply prints out the parameters it is passed. Without any arguments it would do nothing, but giving it arguments does something: > print foobar. –  Synetech Feb 24 '12 at 6:45
    
@Andrea then it doesn't do nothing unless given no arguments. Though that is nothingy enough as per his requirements. –  barlop May 23 '13 at 8:48
    
i think rundll32.exe is beaten by hh.exe (See answer somebody posted in april). if taking size into account, hh.exe is less characters in length of filename. it resides in c:\windows which is even smaller path than c:\windows\system32, and is smaller in size at 16KB. Though both are probably beaten by synetech's assembly language post. –  barlop May 23 '13 at 8:54

There aren't any programs included with Windows (that I know of) which immediately exit when executed (at least on purpose.)

In Windows Vista and newer, however, there is the timeout.exe utility. Timeout.exe will wait a specified number of seconds and then exit. For example:

C:\>timeout /t 0 > nul:

Setting timeout.exe to wait for 0 seconds is about as close as a you'll get to an EXE that immediately exits.

share|improve this answer
3  
To do what the Op wants, use timeout like this "timeout /t 0 > nul:" - which will run the timeout command without any output and will quit immediately. –  misterjaytee Jan 22 '12 at 10:05
    
@misterjaytee good idea. –  Andrew Lambert Jan 22 '12 at 10:08
    
@Tom: A console window. It won't open a command prompt unless you run cmd.exe specifically. –  grawity Jan 22 '12 at 15:02
    
@grawity: The Task Scheduler needs a command processor for the command to run, hence the console window will briefly show. –  Tom Wijsman Jan 22 '12 at 18:06
    
@TomWijsman Try as I might, I can't get any new window to open up. –  Andrew Lambert Jan 22 '12 at 18:44

wscript with no arguments runs no script at all, and is a "GUI" executable (does not open a console).

share|improve this answer
    
When I run wscript with no arguments I get a "Windows Script Host Settings" that appears. Windows 7 64-bit. Running wscript /b seems to work though. –  DuckMaestro Jan 22 '12 at 22:37

Altough it is not the main purpose of this tool, you can use the /donothing option of WuInstall - you can also specify a return code which should be returned - see http://help.wuinstall.com

share|improve this answer
    
That does not seem to be included with XP or 7. Is it included with Server versions? –  Synetech Feb 24 '12 at 6:48

the command echo off does nothing within a batch (.BAT) file. Although it is not an executable it is an windows internal command.

share|improve this answer
3  
Actually it does do something, it turns echoing off. That might seem like nothing if you have it set to off, but if you want echoing, then it certainly does do something. –  Synetech Feb 24 '12 at 6:47
2  
and like rem, it's not a windows exe –  barlop Mar 1 '12 at 19:40

Compile a simple "Hello World" C++ program to create a simple exe which would exit immediately.
Save following code in a text file with some name like a.cpp:

#include<iostream>
int main()
{ std::cout<<"Hello World";
return 0;
}

Then, compile it with LATEST C++ compiler like MinGW for Windows 7.
In case of MinGW, execute following command in PowerShell or Command Prompt: g++ path\a.cpp (Assuming that you have set environmental PATH variable of g++ binary location or you are in g++ binary directory i.e. c:\mingw\bin by default). After command execution, you will get a.exe which will display Hello World and exit. Verify by double-click... cmd window will appear and disappear immediately. Command line access will display Hello World and return you to CLI prompt.
Then, you can move this a.exe in system32 or anywhere deep inside Windows. You can even roll it out in installation disk of Windows.

share|improve this answer
2  
I’m pretty sure that a C++ compiler is not included with Windows. –  Synetech Feb 24 '12 at 6:51
4  
Printing "Hello World" is hardly doing nothing. –  Keith Thompson Feb 24 '12 at 7:17
    
@Synetech Compilation is required only one time as long as CPU architecture is same.. –  Sachin Shekhar Feb 24 '12 at 15:18
1  
@KeithThompson I don't think it would interference with BAT algorithm, but if it really matters, replace Hello World with ASCII null character.. –  Sachin Shekhar Feb 24 '12 at 15:21
4  
> I don't think it would interference with BAT algorithm, but if it really matters, replace Hello World with ASCII null character Or just remove the print command altogether. –  Synetech Feb 24 '12 at 17:13

Is there a "noop"-esque exe somewhere as part of the Windows installation?

Meaning specifically a program that is meant to do nothing and nothing else? Yes and no. No in that Windows does not include one by default, but it does include the ability to make one yourself.


Option 1

Run notepad.exe, type the following lines, and save it as C:\ret.scr (don’t forget the blank line):

a
ret

rcx
1
n ret.com
w
q

Compile it with debug.exe at the command-prompt (cmd.exe) with following command:

C:\> debug < ret.scr

You now have a program, ret.com (in C:\) that can be used in batch files which does absolutely nothing whatsoever (well, other than quit, if that counts).

Note: debug is not included on 64-bit systems.


Option 2

In Vista and up, the .NET framework is included by default, so you could also make a native, Windows do-nothing .exe with C# (64-bit compatible):

Run notepad.exe and type the following lines, saving it as C:\ret.cs:

class rte
{
   static void Main() {
   }
}

Compile it with csc.exe at the command-prompt (cmd.exe) with the following command:

C:\> csc ret.cs

You now have another program, ret.exe (in C:\) that can be used in batch files which does nothing but return.

share|improve this answer
1  
Damn Brilliant.. everybody should upvote you for that one.. I always wanted to learn assembly language.. I never used debug and thought it died with DOS. So glad I stumbled on your answer here. maybe fodder for a future hobby! –  barlop Feb 24 '12 at 14:16
5  
For me, csc.exe was not on my path, but it was located at C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe –  AlcubierreDrive Aug 3 '12 at 4:24
    
what about an EXE which is compiled from a C program which just has a main method, like your csc.exe Is that doing much much more than the program you wrote in debug? for example, is there much much more assembly language there with that program? –  barlop May 23 '13 at 8:51
    
@barlop, generally yes. While an empty main function seems like it would, or at least should be nothing more than a ret, if you open such a program in a disassembler (or even a hex-editor), you will see that it is much, much more than that. It will usually set up all kinds of segments (code, data, etc.), prepare stacks and heaps, not to mention import all kinds of functions and strings and such even if it never actually uses them. –  Synetech May 24 '13 at 19:12

Without parameters "C:\Windows\hh.exe" (Microsoft® HTML Help Executable) does nothing and it is included in any Windows-Version I guess.

share|improve this answer

You can write a no-op in C like so

void main() {
  ;
}

and compile it into an .exe file. For example, if you have Visual Studio installed, you can open notepad, paste that snippet, save it as noop.c and in the command prompt use cl noop.c and it will output a noop.exe file in the same folder.

You may or may not have to browse to the Microsoft Visual Studio X.0 folder in Program Files first and run vcvarsall.bat from the command prompt.

share|improve this answer

protected by Oliver Salzburg May 1 '13 at 10:53

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.