Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Executing exe in others' user context???

Executing exe in others' user context???

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sandeepkavade
    wrote on last edited by
    #1

    Hi, i want to execute a exe in other's context so i tried the following code HANDLE hUserToken; LogonUser(_T("username"),_T("domain"), _T("password"), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUserToken); STARTUPINFO startupInfo; memset(&startupInfo, '\0', sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); startupInfo.dwFlags = STARTF_USESHOWWINDOW; startupInfo.wShowWindow = SW_SHOW; PROCESS_INFORMATION procInfo; memset(&procInfo, '\0', sizeof(procInfo)); BOOL b = CreateProcessAsUser(hUserToken, fileName.c_str(), NULL, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, &procInfo); DWORD dw = GetLastError(); } but i get the dw = 1314 saying "A required privilege is not held by the client." If i right click the exe and choose the run as option giving user name and password it works fine. but how to execute that through code? Where i am going wrong?

    R 1 Reply Last reply
    0
    • S sandeepkavade

      Hi, i want to execute a exe in other's context so i tried the following code HANDLE hUserToken; LogonUser(_T("username"),_T("domain"), _T("password"), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUserToken); STARTUPINFO startupInfo; memset(&startupInfo, '\0', sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); startupInfo.dwFlags = STARTF_USESHOWWINDOW; startupInfo.wShowWindow = SW_SHOW; PROCESS_INFORMATION procInfo; memset(&procInfo, '\0', sizeof(procInfo)); BOOL b = CreateProcessAsUser(hUserToken, fileName.c_str(), NULL, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, &procInfo); DWORD dw = GetLastError(); } but i get the dw = 1314 saying "A required privilege is not held by the client." If i right click the exe and choose the run as option giving user name and password it works fine. but how to execute that through code? Where i am going wrong?

      R Offline
      R Offline
      Rajkumar R
      wrote on last edited by
      #2

      sandeepkavade wrote:

      but how to execute that through code?

      [Starting an Interactive Client Process in C++^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups