29
votes

Using the ShellExecute documentation as a reference:

I run the following from the command line:

C:\>RUNDLL32.EXE SHELL32.DLL,ShellExecute handle,"open","C:\Documents and Settings\admin\Desktop\tmp",NULL,NULL,SW_SHOWNORMAL

This results in an exception error.

I don't know what this means:

HINSTANCE ShellExecute(
  __in_opt  HWND hwnd,
  __in_opt  LPCTSTR lpOperation,
  __in      LPCTSTR lpFile,
  __in_opt  LPCTSTR lpParameters,
  __in_opt  LPCTSTR lpDirectory,
  __in      INT nShowCmd
);

But in the description, a handle (HWND), and a pointer to a null-terminated string (LPCTSTR), are mentioned, but it is very confusing.

Any help would be greatly appreciated. I would also like to learn more, so any references (book, web links, etc) would also be great!

1
It would be helpful if you explained what you're trying to accomplish since there may be better ways than using RUNDLL32. Regrdless, you are not calling RUNDLL32 correctly. For example, parameters must be separated by spaces (comma only separates entry point from DLL), hwnd and nShowCmd expect integer values, etc. See support.microsoft.com/kb/164787 for more info.Alek Davis
I am a wandering head. I read: vlaurie.com/computers2/Articles/rundll32.htm. Then I started looking at different dll files, and found this: msdn.microsoft.com/en-us/library/bb776426%28v=VS.85%29.aspx. I started to look at the individual functions, and wondered if they could be used with rundll32.exe. I picked the ShellExecute function because I understand what it does (open a folder). I am mainly trying to learn how these things work (in MSDN). I don't even know if it is C, C++, C#, etc.mike

1 Answers

30
votes

Rundll32 only supports running DLL exports with the following signature:

void CALLBACK
  EntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);

It does not support running arbitrary entry points. Since ShellExecute does not have that signature, clearly bad things will happen.

INFO: Windows Rundll and Rundll32 Interface has more info on the rundll32 interface.

If you want to do the equivelent of ShellExecute from the command line, just use start:

C:\>start "C:\Documents and Settings\admin\Desktop\tmp"