1
Reply

STARTING AN APPLICATION FROM A NON-INTERACTIVE WINDOWS SERVICE IN WINDOWS 7

Immi

Immi

Apr 6 2011 3:51 AM
2.1k

I have developed a windows service in VS 2008 which launches another application at my local computer. The launched application has a UI, so, I used CreateProcessAsUser API to launch the application (start the process).

 

Private Function CreateProcessAsUser(

ByVal hToken As IntPtr,

ByVal lpApplicationName As String,

ByVal lpCommandLine As String,

ByRef lpProcessAttributes As SECURITY_ATTRIBUTES,

ByRef lpThreadAttributes As SECURITY_ATTRIBUTES,

ByVal bInheritHandles As Boolean,

ByVal dwCreationFlags As UInteger,

ByVal lpEnvironment As IntPtr,

ByVal lpCurrentDirectory As String,

ByRef lpStartupInfo As STARTUPINFO,

ByRef lpProcessInformation As PROCESS_INFORMATION

) As Boolean

 

The application is running fine in windows xp but in windows 7, I got the privileges error i.e. the application launched by windows service is not running with 'Administrator' rights.

 

I have also tried 'System.Diagnostics.Process' and 'ShellExecuteEx' methods to launch my application with 'Administrator' rights from windows service, although the application is launched with 'Administrator' rights, but its running in backgroud i.e. no UI is displayed on the current users desktop.

 

Please help me in this regard.

 

Thanks in advance.

Answers (1)