Windows run file as executable

how to run an executable file without EXE extension using CMD script?

The situation is that I have a portable application that needs to have set environment variable. Other way it tries to set it’s settings in user program data dir.

To avoid running the executable in non-portable mode (to avoid allowing it to run without any parameters) I erased the file’s «.exe» extension, but then I cannot run it not only by mouse (which I want) but also through start command.

Is there any way to run such executable file that has no exe extension ?

3 Answers 3

Yes – simply entering the program’s full filename usually works. (The .exe requirement only exists in the GUI shell.)

(It might be that the file needs an extension, though – so if you can’t get MyProgram to run, rename it to MyProgram.notexe or MyProgram.lol and try again.)

Any file with any extension and first two bytes MZ will be treated like an EXE.

  1. Create a new a.txt file,
  2. Type in it MZ , save it.
  3. Open cmd , go to its folder,
  4. Type a.txt and see the error message.

Replace MZ with MS and try again — this time notepad will run with file opened.

I tried to run process from file without the .exe extension. When I failed to do so from cmd.exe I give a try some powershell commands. Here is one:

The documentation says about Default syntax and UseShellExecute. With just:

the command uses UseShellExecute syntax and returns error about not associated application to that file type. To force the Default syntax I added parameter that the UseShellExecute doesn’t have:

My program was started and wrote output to the console. This was enough for me, because I needed it only for test purpose.

How to run a file as executable with a different extension?

After taking a look at the listed processes in Window’s TaskManager, I’ve noticed that there are some process that has a different extension other than .exe. I then opened the folder location of one of those processes and their extension is the same as they are shown in TaskManager. So, I was wondering how they do it. I just wanted to learn how its done.

I’ve tried renaming my application with a different extension and it didn’t run.

Why am I seeking answers to this question? For security purposes.

2 Answers 2

Indirectly, the command line «start foo.abc» will run an executable renamed from foo.exe.

More directly, edit the registry. In HKEY_CLASSES_ROOT , create a new Key with the name .abc. and set the default value to abcfile .

Читайте также:  Где включить брандмауэр windows

Under abcfile , make key, name it Shell , and under that, create a new key named open , and under that, create another key named command . Now copy the contents from exefile and copy the contents over. You may want to search for other instances if «.exe» in the registry to find the appropriate contents, as they seem to change from across Windows versions.

This all of course assumes you have administrator access, because you would of course not do this on any system but your own. 🙂

open up cmd prompt type: start pathOfFile\file.pdf /c vshost.exe

this will run your file with pdf extension as .exe or any other you wanna give

don’t misuse it, think someone helped you out, before harming any one

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

How to create an executable C file for Windows

I know this question has been asked several times and I took a look at many of them like

Unfortunately, none of them worked for me.

My situation

I’ve installed Ubuntu and Windows on my Notebook.

  • Let’s say I developed a simple «Hello,World!» program using a text editor in c.
  • In Ubuntu, I’ve compiled it using GCC $ gcc -o hello.out -g -Wall -pedantic hello.c
  • I executed it ‘./output.out’
  • And got the result Hello, World!

What I tried

So I kind of cross-developed here. I switched to Windows and kept going.

Now, I try to make it an executable file in order to run it on Windows. I know Windows can’t handle ‘$ ./output.out’ , alright, let’s make it an executable then.

Under Windows, I’ve

  • installed cygwin
  • In Cygwin, I compiled it using GCC $ gcc -o hello.exe -g -Wall -pedantic hello.c

Note: I wrote hello.exe instead of hello.out or hello.c

  • In Cygwin, I executed it ‘$ ./output.exe’
  • And got the result Hello, World!

Note: At this point, it even works with my Shell under Windows because I installed Cygwin and set up my PATH etc. This means I can open my command line, go to the directory in which ‘hello.exe’ is located and execute it by typing ‘> hello.exe’

I thought that would be it, so I took hello.exe’ and moved it to another notebook (not my local machine). I tried to execute it but it didn’t work.

At first, I got an cygwin1.dll missing message. After fixing it, another error appears.

What I’m trying to accomplish

To make a long story short: The reason I wrote so much is that I want to give you a detailed look of my situation.

Basically, I’m trying to create an executable c file, which any Windows User could execute without having any development tools.

Читайте также:  Linux create file in directory что это

In Eclipse and Java, you could simply export your program making it a runnable -jar file. All the User has to do is install the latest Java SE version to get it running.

Additionally, I tried to compile my program in Visual Studio but that didn’t work either.

How do I execute a *.dll file [closed]

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 5 months ago .

I have a DLL file and I want to execute it on Windows. I obtained this DLL file from a challenge site which alleges the DLL should be executed independently.

9 Answers 9

To run the functions in a DLL, first find out what those functions are using any PE (Portable Executable) analysis program (e.g. Dependency Walker). Then use RUNDLL32.EXE with this syntax:

dllname is the path and name of your dll file, entrypoint is the function name, and optional arguments are the function arguments

You can execute a function defined in a DLL file by using the rundll command. You can explore the functions available by using Dependency Walker.

While many people have pointed out that you can’t execute dlls directly and should use rundll32.exe to execute exported functions instead, here is a screenshot of an actual dll file running just like an executable:

While you cannot run dll files directly, I suspect it is possible to run them from another process using a WinAPI function CreateProcess:

DLLs are shared libraries which are used by other windows programs while EXEs are the files which are actually executed and are linked to DLL files so that they can use DLLs.
Both are of same format, PE(portable executable or format of machine code in windows in simple words).
In other words EXEs contain the entry point(main) and the DLLs contain the library functions.. You cannot execute a file which just contains library functions you can just use them via other programs.

But still there are programs like rundll32.exe which provides that entry point and some minimal framework required by DLL functions to be called.
The point that I want to make is, you can never execute a DLL file you can just use it’s code by providing an entry point through an EXE or some other program.

Create Windows service from executable

Is there any quick way to, given an executable file, create a Windows service that, when started, launches it?

10 Answers 10

To create a Windows Service from an executable, you can use sc.exe :

You must have quotation marks around the actual exe path, and a space after the binPath= .

Note that it will not work for just any executable: the executable must be a Windows Service (i.e. implement ServiceMain). When registering a non-service executable as a service, you’ll get the following error upon trying to start the service:

Error 1053: The service did not respond to the start or control request in a timely fashion.

There are tools that can create a Windows Service from arbitrary, non-service executables, see the other answers for examples of such tools.

Читайте также:  Igo primo карты 2020 windows ce

Use NSSM( the non-Sucking Service Manager ) to run a .BAT or any .EXE file as a service.

  • Step 1: Download NSSM
  • Step 2: Install your sevice with nssm.exe install [serviceName]
  • Step 3: This will open a GUI which you will use to locate your executable

Extending (Kevin Tong) answer.

Step 1: Download & Unzip nssm-2.24.zip

Step 2: From command line type:

C:\> nssm.exe install [servicename]

it will open GUI as below (the example is UT2003 server), then simply browse it to: yourapplication.exe

Many existing answers include human intervention at install time. This can be an error-prone process. If you have many executables wanted to be installed as services, the last thing you want to do is to do them manually at install time.

Towards the above described scenario, I created serman, a command line tool to install an executable as a service. All you need to write (and only write once) is a simple service configuration file along with your executable. Run

will install the service. stdout and stderr are all logged. For more info, take a look at the project website.

A working configuration file is very simple, as demonstrated below. But it also has many useful features such as and

these extras prove useful.. need to be executed as an administrator

If your service name has any spaces, enclose in «quotes».

I’ve tested a good product for that: AlwaysUp. Not free but they have a 30 days trial period so you can give it a try.

Same as Sergii Pozharov’s answer, but with a PowerShell cmdlet:

See New-Service for more customization.

This will only work for executables that already implement the Windows Services API.

You can check out my small free utility for service create\edit\delete operations. Here is create example:

Go to Service -> Modify -> Create

Executable file (google drive): [Download]

Probably all your answers are better, but — just to be complete on the choice of options — I wanted to remind about old, similar method used for years:

SrvAny (installed by InstSrv)

I created the cross-platform Service Manager software a few years back so that I could start PHP and other scripting languages as system services on Windows, Mac, and Linux OSes:

Service Manager is a set of precompiled binaries that install and manage a system service on the target OS using nearly identical command-line options (source code also available). Each platform does have subtle differences but the core features are mostly normalized.

If the child process dies, Service Manager automatically restarts it.

Processes that are started with Service Manager should periodically watch for two notification files to handle restart and reload requests but they don’t necessarily have to do that. Service Manager will force restart the child process if it doesn’t respond in a timely fashion to controlled restart/reload requests.

Оцените статью