Rapid7 Vulnerability & Exploit Database

Windows Run Command As User

Back to Search

Windows Run Command As User



This module will login with the specified username/password and execute the supplied command as a hidden process. Output is not returned by default. Unless targeting a local user either set the DOMAIN, or specify a UPN user format (e.g. user@domain). This uses the CreateProcessWithLogonW WinAPI function. A custom command line can be sent instead of uploading an executable. APPLICAITON_NAME and COMMAND_LINE are passed to lpApplicationName and lpCommandLine respectively. See the MSDN documentation for how these two values interact.


  • Kx499
  • Ben Campbell <eat_meatballs@hotmail.co.uk>




Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/windows/local/run_as
msf exploit(run_as) > show targets
msf exploit(run_as) > set TARGET < target-id >
msf exploit(run_as) > show options
    ...show and set options...
msf exploit(run_as) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security