user118708
user118708

Reputation: 327

Run process as Local System

I have a regular program running as an Administrator process. But it doesn't quite have all the privileges I need. How do I elevate this process to run as the Local System account ?

I don't want to use any externals tools to achieve this elevation. It would be ideal if I could call some Win32 functions to achieve it. I am also willing to write and run a Windows service in order to pass its privileges onto the process in question.

Someone please give me a clue. My searches are just sending me round and round in circles.

Upvotes: 1

Views: 2721

Answers (1)

user118708
user118708

Reputation: 327

  1. Program sends session ID to service
  2. Service calls OpenProcessToken and DuplicateTokenEx to create a Local System token
  3. Service calls SetTokenInformation to change the token session ID to match the program's
  4. Service calls DuplicateHandle to create handle to the token
  5. Service sends handle to program
  6. Program calls SetThreadToken using the received handle

The program will have at least one thread with Local System privileges. This will be adequate for my purpose.

Upvotes: 1

Related Questions