Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I have made a windows service in .Net 4.5. I want to check if the explorer.exe process is started or not on the machine through my service and if not, then start the process.
 
i have heard about the difference between sessions that win service runs in session 0 and all other processes runs in session 1 of windows. may that's why i am unable to start the explorer.exe from my service.
 
I have tried till now :
 
method : 1
<pre lang="vb">Dim pro As New ProcessStartInfo("C:\Windows\explorer.exe")
        pro.UseShellExecute = True
        Process.Start(pro)
 
method : 2
Shell("C:\Windows\explorer.exe", AppWinStyle.MaximizedFocus)
 
method : 3
Process.Start("C:\Windows\explorer.exe")
 
but couldn't apply any of them successfully.. please help me out..
Posted 28-Mar-13 7:25am
Comments
ThePhantomUpvoter at 28-Mar-13 12:47pm
   
I don't really have an answer to this but this does not make any sense to me. I would think that if explorer was not already running, then neither is your service. Can you maybe explain a scenario where you would need to start explorer since it should already be running anyway.
Vivek-The Geek at 29-Mar-13 1:13am
   
actually i have made a metro style app that will authenticate the user after he has logged into windows. i have managed somehow to put my metro app in startup using task scheduler and a script.
 
the windows service will continuously check for a value in my database (.xml file) i.e. is the user authenticated or not.
 
if the user is authenticated, then check for explorer is started or not, if NOT STARTED THEN START IT.
 
if the user is NOT authenticated, then again check for explorer is started or not, if YES THEN KILL EXPLORER.EXE.
 
the value in my database (.xml file) will be changed only after the user authentication through my metro app.
 
Hope u got it my concept, if any query, just ask me..
Sergey Alexandrovich Kryukov at 28-Mar-13 13:22pm
   
Why doing all that? All solutions make no sense because nothing can guarantee that Explorer.EXE is located there. There are no situations when hard-coded path names can be useful.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can't do this. If your code worked at all, Explorer would be running in Session 0, completely invisible to the user logged in that the desktop. Actually, IIRC, Explorer won't even launch in Session 0.
 
As of Windows Vista, Services can no longer interact with the users session. This is because of the security risks involved.
 
You cannot do what you want to do.
 
Besides, there's really no reason to do this at all. If Explorer is killed off, the system will restart it automatically. If, however, Explorer fails to start, this means the system is in such a screwed up state that it needs to be restarted anyway.
  Permalink  
Comments
Vivek-The Geek at 29-Mar-13 1:19am
   
let me explain my concept which i want to achieve.
 
actually i have made a metro style app that will authenticate the user after he has logged into windows. i have managed somehow to put my metro app in startup using task scheduler and a script.
 
the windows service will continuously check for a value in my database (.xml file) i.e. is the user authenticated or not.
 
if the user is authenticated, then check for explorer is started or not, if NOT STARTED THEN START IT.
 
if the user is NOT authenticated, then again check for explorer is started or not, if YES THEN KILL EXPLORER.EXE.
 
the value in my database (.xml file) will be changed only after the user authentication through my metro app.
 
i hope now u can help me out.
 
Can u make me a VB.Net snippet that will derive the user's ID and token from session 1 and then i can call the explorer.exe by providing it the user's session details.
 
Sorry for my poor english as its not my first language..
Dave Kreskowiak at 29-Mar-13 9:40am
   
You're, apparently, not listening. YOU CANNOT DO THIS! You're entire concept is FATALLY FLAWED. You can NOT kill Explorer.exe with it automatically restarting itself. You can NOT launch a process from one session in another session, reguardless if you have the logged on users security token.
 
This can NOT be fixed!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

What error is returned when your code fails to start explorer?
 
And what version of Windows are you working on? Session 0 Isolation in Windows Vista and beyond may affect your approach...
  Permalink  
Comments
Vivek-The Geek at 29-Mar-13 1:05am
   
Actually my windows service will work with my metro application simultaneously. Therefore, the service will be run only in windows 8.
 
No error occurs while starting the explorer, still it doesn't start.. sorry for my poor english.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100