-
March 22nd, 2010, 02:46 PM
#1
Create Process doesn't show any window
Hi there,
i'm having problems creating a process inside a service, which runs as a user (not LocalSystem).
The issue is that it creates the process, but without showing the dialog of the application or the tray icon. I can say that the application works fine, cause it is a kind of alerter that play a sound when an event occurs.
The user is the default user, which it's constantly logged in.
I've tried with both ShellExecute and CreateProcess obtaining the same results.
Running the service as LocalSystem (with the SERVICE_INTERACTIVE_PROCESS flag) instead created the process and showed the dialog and the icon.
I must run it as that specific user cause that executable reads some opts (ie:username) from an .ini which is used by other components.
Have any idea?
-
March 22nd, 2010, 03:02 PM
#2
Re: Create Process doesn't show any window
-
March 22nd, 2010, 03:57 PM
#3
Re: Create Process doesn't show any window
HANDLE hToken;
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
LogonUser( _T("user"),
_T("."),
_T("password"),
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
&hToken);
CreateProcessAsUser( hToken,
_T("C:\\the\\App.exe"),
NULL,
NULL,
NULL,
FALSE,
CREATE_NEW_PROCESS_GROUP,
NULL,
_T("C:\\wp"),
&si,
&pi);
CloseHandle(hToken);
Where am I wrong? I get the app running, it shows the dialog, but it crashes instantly...
Last edited by Enrorr; March 22nd, 2010 at 04:00 PM.
-
March 22nd, 2010, 06:01 PM
#4
Re: Create Process doesn't show any window
Originally Posted by Enrorr
Where am I wrong? I get the app running, it shows the dialog, but it crashes instantly...
What happens when you step through the code in a debugger? Why aren't you checking the return values of the api calls?
At any rate, even if you get this running are you aware that this approach won't work on Vista or Win7?
-
March 23rd, 2010, 05:35 AM
#5
Re: Create Process doesn't show any window
Did you read the article, CILU pointed you to? Why not?
Services do not have a desktop to interact with (unless they run as local system and are configured "interactive").
However you can pass information about the desktop in the STARTUPINFO structure of CreateProcess (AsUser).
See http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
and http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
regards
HoM
-
March 23rd, 2010, 02:01 PM
#6
Re: Create Process doesn't show any window
Originally Posted by Arjay
What happens when you step through the code in a debugger? Why aren't you checking the return values of the api calls?
At any rate, even if you get this running are you aware that this approach won't work on Vista or Win7?
That was just a quick post. I checked the returns and everything's fine.
I think that shouldn't work on vista/win 7. But I'm just helping a co-worker with some legacy monitoring software that just runs on win xp.
Since it's a service and I have about no knowledge in programming, I couldn't figure out how to debug a running service.
@HoM:
Yeah i read it, indeed running it as SYSTEM and interactive works.
So tell if I'm understanding the whole thing: a service running as the user who is currently logged in (or another user apart from SYSTEM) can't interact with the desktop, unless I specify the desktop, since "If the thread did not call SetThreadDesktop, it connects to the desktop inherited from the parent process" and since the parent process is a service my new process can't get the desktop the human user is currently using?
By the way, I'm curious how the desktops are named? I've seen that OpenDesktop wants a string as input.
Oh and thanks everybody for the hints and patience
Last edited by Enrorr; March 23rd, 2010 at 02:23 PM.
-
March 24th, 2010, 08:00 AM
#7
Re: Create Process doesn't show any window
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
is about EnumDesktops, which can give you the info about all Desktops of a Windowstation in a Callback function
EnumWindowStations can be used to enumerate WindowStations. So with this you can get every information.
BTW: The default Windowstation from an interactive login is "Winsta0", the default Desktop is named "default"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|