Click here to Skip to main content
15,891,895 members
Home / Discussions / C#
   

C#

 
Question2 Questions Pin
JMOdom27-Mar-07 7:35
JMOdom27-Mar-07 7:35 
AnswerRe: 2 Questions Pin
led mike27-Mar-07 7:48
led mike27-Mar-07 7:48 
AnswerRe: 2 Questions Pin
Leslie Sanford27-Mar-07 7:55
Leslie Sanford27-Mar-07 7:55 
GeneralRe: 2 Questions Pin
JMOdom27-Mar-07 11:02
JMOdom27-Mar-07 11:02 
GeneralRe: 2 Questions Pin
Leslie Sanford27-Mar-07 11:14
Leslie Sanford27-Mar-07 11:14 
AnswerRe: 2 Questions Pin
Rudolf Jan28-Mar-07 0:10
Rudolf Jan28-Mar-07 0:10 
GeneralRe: 2 Questions Pin
JMOdom28-Mar-07 13:27
JMOdom28-Mar-07 13:27 
QuestionSystem.Diagnostics.Process.StartInfo Username= "default user"? Pin
Austin Harris27-Mar-07 6:59
Austin Harris27-Mar-07 6:59 
Hello,

Problem is that I am trying to launch a windows forms application process from the context of a windows service, via a intermediate update process.

The service launches the update process just fine. The update process determines if it needs to shutdown the service and apply an update to it. It then restarts the service. This update process is currently launching under the context of the service. IE: Its parent process is the service process, and is owned / its User is "NT Authority\System".

Everything is fine to this point. After the service is updated and restarted I then have to open a windows form application (the service's controlling interface) "IF" there is a user logged into the system, and it must run under that users account (I believe).

I launch the interface process like so:
<br />
 // launch the UI<br />
Process process = new Process();<br />
process.StartInfo.UseShellExecute = true;<br />
process.StartInfo.RedirectStandardOutput = false;<br />
process.StartInfo.RedirectStandardError = false;<br />
process.StartInfo.FileName = Application.StartupPath + "\\serviceInterface.exe";<br />
process.StartInfo.Arguments = " -updated";<br />
process.StartInfo.LoadUserProfile = true;<br />
process.StartInfo.WorkingDirectory = Application.StartupPath;<br />
process.StartInfo.CreateNoWindow = false;<br />
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;<br />
process.Start();<br />


The process starts and is diplayed under processes in taskmanager. It does not get a window handle though it seems.
Whatever I try I cannot bring the process to focus. If I try to bring the processes main window to front I get an error that there is no window associated with the process.

I have determined that the problem roots from the user account that the process is launched under, as when I lauch the update process manually under the default users account every thing works fine.

Hard coding a username and password is not an option as I would then have to create that account on each machine the service is installed on.

How can I get my process to start under the context of the local users account, if there is one logged in? Also what if there are mutlipule terminal sessions open to the server, how do I pick the approperate one to launch under?

Thanks a ton for any info.

Been stumped here for a little bit.
AnswerRe: System.Diagnostics.Process.StartInfo Username= "default user"? Pin
kubben27-Mar-07 7:57
kubben27-Mar-07 7:57 
GeneralRe: System.Diagnostics.Process.StartInfo Username= "default user"? Pin
Austin Harris27-Mar-07 8:48
Austin Harris27-Mar-07 8:48 
GeneralRe: System.Diagnostics.Process.StartInfo Username= "default user"? Pin
kubben27-Mar-07 9:19
kubben27-Mar-07 9:19 
QuestionAuto generated number Pin
Neo_Shehpar27-Mar-07 6:44
Neo_Shehpar27-Mar-07 6:44 
AnswerRe: Auto generated number Pin
Leslie Sanford27-Mar-07 7:23
Leslie Sanford27-Mar-07 7:23 
GeneralRe: Auto generated number Pin
Christian Graus27-Mar-07 7:26
protectorChristian Graus27-Mar-07 7:26 
AnswerRe: Auto generated number Pin
Christian Graus27-Mar-07 7:24
protectorChristian Graus27-Mar-07 7:24 
AnswerRe: Auto generated number Pin
Austin Harris27-Mar-07 7:27
Austin Harris27-Mar-07 7:27 
AnswerRe: Auto generated number Pin
kubben27-Mar-07 7:42
kubben27-Mar-07 7:42 
GeneralRe: Auto generated number Pin
Austin Harris27-Mar-07 8:52
Austin Harris27-Mar-07 8:52 
GeneralRe: Auto generated number Pin
kubben27-Mar-07 9:13
kubben27-Mar-07 9:13 
AnswerRe: Auto generated number Pin
Neo_Shehpar29-Mar-07 11:02
Neo_Shehpar29-Mar-07 11:02 
Questionhow to get logged in user name Pin
Nkuttynasi27-Mar-07 6:40
Nkuttynasi27-Mar-07 6:40 
AnswerRe: how to get logged in user name Pin
Not Active27-Mar-07 6:46
mentorNot Active27-Mar-07 6:46 
QuestionTranspose - Converting columns to rows Pin
BanarasiBhaiya27-Mar-07 6:33
BanarasiBhaiya27-Mar-07 6:33 
QuestionQuickly need a listing of classes/methods/signatures - how? Pin
sherifffruitfly27-Mar-07 6:21
sherifffruitfly27-Mar-07 6:21 
AnswerRe: Quickly need a listing of classes/methods/signatures - how? Pin
Christian Graus27-Mar-07 6:30
protectorChristian Graus27-Mar-07 6:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.