Home > Back-end >  O people Service Service program can call external exe normal execution code!
O people Service Service program can call external exe normal execution code!

Time:10-03

I wrote a service program, to the external call an EXE program (the program is to generate a desktop shortcut!) Works all normal, normal in the desktop! But by the service to invoke cannot take effect! O can solve the problem of code!
After checked baidu know, seemed very complicated!!!!! For a simple example to study ~ ~ ~ I am using Delphi 2010! If we can get rid of! I 200 points!

CodePudding user response:

For a complete DEMO,,,,,,,

CodePudding user response:

Online to find the process of hint ~ ~ ~
The same code works for us on Vista as on XP, etc. The service is running as The Local System.

1. Use WTSGetActiveConsoleSessionId to get the ID of the current active Windows session at the console (i.e. for the machine the rid_device_info_keyboard and display, as opposed to WTS sessions).

2. Use WTSQueryUserToken to get the token for that session.

3. Use DuplicateTokenEx (hToken MAXIMUM_ALLOWED, NULL, SecurityIdentification TokenPrimary, & amp; HTokenDup) to duplicate that token.

4. Use CreateEnvironmentBlock to create an environment that will be passing to the process.

5. Use CreateProcessAsUser have the duplicated token and the created environment. Later, we use CreateProcessAsUserW, since the A version had some sort of bug on some older systems.

6. Don 't forget to CloseHandle on the various tokens, etc, and DestroyEnvironmentBlock the environment.

CodePudding user response:

Nice ah, ~ ~ ~ ~

CodePudding user response:

To generate a desktop shortcut should be no problem, as long as enough permissions
The key is to which a user? Service is running in a special session

CodePudding user response:

With the current user to run, I run directly and call is normal, but in my own service program called directly not,,

CodePudding user response:

If the above system is Windows 7, allow the service to service needs to be checked with desktop interactive options,
  • Related