0

I must enter a username/password within a rundll32.exe process window. I've tought of the following:

  1. Get Login window handle from the rundll32.exe process
  2. Focus the window
  3. Inject the text in 2 textbox and click the ok button

Is it possible to do that in .NET or I must resort to lower level win32 api? Anywone as done that before and could point me in the right direction?

Machinegon
  • 1,855
  • 1
  • 28
  • 45
  • What are you actually trying to do? Get the user to enter a licence key or similar? Or is it their windows login you need? Are you trying to make them register as an admin? – Ben Oct 30 '13 at 13:45
  • @Ben I'm trying to enter the username/password inside an exchange mapi profile previously created by the code. The mapi32.dll api does not exposes functions to provide the credentials, it takes them from the windows account and prompt for a password if they do not match the exchange account in the AD(which is the case). I need to retreive this window prompt and inject the credentials to make sure everything stays fully automatic – Machinegon Oct 30 '13 at 13:55
  • OK so you are attempting to retrieve the window handle of the Exchange login dialog of the MAPI application (probably outlook), FROM a rundll32.exe process... http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx. Alternatively you could establish the NETBIOS session in advance using NetUseAdd to establish a session.... http://msdn.microsoft.com/en-us/library/windows/desktop/aa370645(v=vs.85).aspx – Ben Oct 30 '13 at 14:19

1 Answers1

1

You are attempting to retrieve the window handle of the Exchange login dialog of the MAPI application (probably outlook), FROM a rundll32.exe process. This can be done from .Net using the SendKeys class, but this is not completely reliable:

Alternatively you could establish the NETBIOS session in advance using NetUseAdd to establish a session. If this is successful, you will not need to enter the username and password. I don't know if this works with Exchange, but it does work with some other applications which use integrated authentication:

Ben
  • 34,935
  • 6
  • 74
  • 113
  • No window handle? I'm able to retrieve it with the windows caption with user32.dll. My attempts to focus the window failed however – Machinegon Oct 30 '13 at 13:32
  • The netbios session is clever, might work. I will give it a try, thanks for the tip – Machinegon Oct 30 '13 at 15:44
  • @Machinegon, try it first by using "NET USE" as in this question: http://stackoverflow.com/questions/5237654/sql-server-management-studio-2008-runas-user-on-different-domain-over-vpn/5362712#5362712 if that works then `NetUseAdd` should work too. – Ben Oct 30 '13 at 15:49