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. Managed C++/CLI
  4. Run an Exe from Windows service

Run an Exe from Windows service

Scheduled Pinned Locked Moved Managed C++/CLI
help
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.
  • N Offline
    N Offline
    nsurendran
    wrote on last edited by
    #1

    Hi , My problem is that, I want to run an .exe from the windows service. But the application window is not visible to the user. Exe and Service is running in task manager. Previously I was using CreateProcess funtion. Then after getting suggestion from this site, I changed that into CreateProcessAsUser and the Code is like below. But Still I am facing same problem. BOOL b; HANDLE hToken; HANDLE hNewToken; b = OpenProcessToken(GetCurrentProcess(), TOKEN_ASSIGN_PRIMARY|TOKEN_DUPLICATE, &hToken); b = DuplicateTokenEx(hToken, TOKEN_ASSIGN_PRIMARY|TOKEN_ALL_ACCESS, NULL, SecurityImpersonation, TokenPrimary, &hNewToken); b = CreateProcessAsUser(hNewToken, NULL,ArgPBU,NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, Cwd, &si, &m_piPBU); CloseHandle(hNewToken); ------------- After executing this I am getting same result. Rgds., N.Surendran

    G 1 Reply Last reply
    0
    • N nsurendran

      Hi , My problem is that, I want to run an .exe from the windows service. But the application window is not visible to the user. Exe and Service is running in task manager. Previously I was using CreateProcess funtion. Then after getting suggestion from this site, I changed that into CreateProcessAsUser and the Code is like below. But Still I am facing same problem. BOOL b; HANDLE hToken; HANDLE hNewToken; b = OpenProcessToken(GetCurrentProcess(), TOKEN_ASSIGN_PRIMARY|TOKEN_DUPLICATE, &hToken); b = DuplicateTokenEx(hToken, TOKEN_ASSIGN_PRIMARY|TOKEN_ALL_ACCESS, NULL, SecurityImpersonation, TokenPrimary, &hNewToken); b = CreateProcessAsUser(hNewToken, NULL,ArgPBU,NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, Cwd, &si, &m_piPBU); CloseHandle(hNewToken); ------------- After executing this I am getting same result. Rgds., N.Surendran

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      Does your service have a main or a WinMain entry point? Also, you should post this in the Viaual C++/MFC forum.

      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