I need to know how I could make a batch file that would execute a dll file as if it was an exe does any one know what I could do I am using windows 7. The file is an exe just with the dll extension.
-
1See here: http://stackoverflow.com/questions/3044395/how-do-i-execute-a-dll-file – Andi Mohr Jan 06 '14 at 13:34
-
The file is an exe just with the dll extension – 09stephenb Jan 06 '14 at 13:35
-
Can you just rename the file to .exe then? – Andi Mohr Jan 06 '14 at 13:36
-
No it needs the dll extension for other reasons but it is just the same as a dll just without the extension. – 09stephenb Jan 06 '14 at 13:37
-
possible duplicate of [How to use Rundll32 to execute DLL Function?](http://stackoverflow.com/questions/3207365/how-to-use-rundll32-to-execute-dll-function) – egur Jan 06 '14 at 14:12
2 Answers
If i understand it, you have a myProgram.exe
file renamed as myProgram.dll
and want to run that executable.
If this is the case then all you need is to directly invoke the file. To test, from command line, from the same directory where the file is, type myProgram.dll
and it will execute. The OS will identify the file as executable an run it.
If you want to execute the program from another directory, and you supply the full path to the executable, it will also work.
BUT if you want to call the executable from another directory without indicating the full path to the executable, using the PATH
variable to locate the program, it will not work.
When a program is search over the folders indicated in PATH
variable, the content of variable PATHEXT
determine the extensions of files to search in PATH
folders. And .dll
is not in this list.
So, or you indicate the full path to the executable (absolute o relative) or include the .dll
extension in the PATHEXT
variable before calling your executable.

- 69,615
- 8
- 84
- 126
If the DLL is a .NET assembly it could be rather easy. For instance, a .NET dll may be accessed from batch file (via) powerhshell like this.
cmd /c start /b Powershell -command "[System.Net.Dns]::GetHostByAddress('8.8.8.8')"
That would allow you to access the .NET system DLL that handles the DNS namespace and call it's methods directly.

- 6,644
- 4
- 26
- 41