-
June 12th, 2014, 09:59 AM
#1
ProcessStart As Current Logged In User - Need Assistance
I am working on what I would have thought was a simple Windows Forms Application. I am using .NET 4.5 & Visual Studio 2013. My idea was to have a "launcher" to open the various applications that gets used.
Our company uses a multitude of custom applications; quoting, application to modify "assemblies" in quoting, measurement tool, etc.
I am curious as to how I could run our permission based applications using Process.Start. It would need to support the domain name, as well as the user. Can this be done via the current logged in user as oppose to the system account? I need some guidance please.
-
June 12th, 2014, 01:49 PM
#2
Re: ProcessStart As Current Logged In User - Need Assistance
If you have a Windows form and use Process.Start, the application being launched will normally be run in the context of the user running the Windows form application.
If the logged on user has permissions to run the app then there is no problem; however, if the user doesn't have permission, Process.Start also has an overloaded method that allows you to pass in the user name and password to run an app under the context of that user.
Unfortunately, that means your app would have to supply the correct un and pw for the app (and that would be a bit of a security hole).
-
June 12th, 2014, 02:02 PM
#3
Re: ProcessStart As Current Logged In User - Need Assistance
Originally Posted by Arjay
If you have a Windows form and use Process.Start, the application being launched will normally be run in the context of the user running the Windows form application.
If the logged on user has permissions to run the app then there is no problem; however, if the user doesn't have permission, Process.Start also has an overloaded method that allows you to pass in the user name and password to run an app under the context of that user.
Unfortunately, that means your app would have to supply the correct un and pw for the app (and that would be a bit of a security hole).
Let me elaborate what I am trying to achieve. An average user in office uses roughly 6 different custom applications per day, not particularly at the same time, but it would be common to close one that won't be needed for an hour or so, then re-open it as needed. There are also a few server shares containing Excel Spreadsheets that are collaborated on. My idea was to create a "screen menu" that is not obtrusive, that would basically launch the different applications we use, and open common spreadsheets that are opened often.
Here is the problem I face, our applications checks for {Domain}\{Username} to launch our applications. Using Process.Start, the user is NTAuthority\System. Back to my original question, am I able to 'get' the current logged in user domain/username and use those for Process.Start function?
-
June 12th, 2014, 03:56 PM
#4
Re: ProcessStart As Current Logged In User - Need Assistance
I understand what you are after. How is the screen menu app getting launched? Does the user launch it? Or is it being run on machine startup before the user logs in (such as through an HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run key)?
-
June 13th, 2014, 07:12 AM
#5
Re: ProcessStart As Current Logged In User - Need Assistance
Originally Posted by Arjay
I understand what you are after. How is the screen menu app getting launched? Does the user launch it? Or is it being run on machine startup before the user logs in (such as through an HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run key)?
The application would get launched manually...for now. I added a message box to display the user...
MessageBox.Show(startInfo.UserName);
This does show the correct domain and username, however the application fails to load.
-
June 13th, 2014, 11:48 AM
#6
Re: ProcessStart As Current Logged In User - Need Assistance
I misread your reply as it didn't start under the user's context. So I wrote a test app to start notepad.
Code:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Press [ENTER] to start notepad.");
Console.ReadLine();
Process.Start(@"C:\Windows\System32\notepad.exe");
Console.WriteLine("Open task manager to see which user notepad is running under.");
Console.ReadLine();
}
}
Then I reread your text and noticed it did start under the correct context.
Well, in that case something else is wrong. Perhaps there are additional command line parameters that you need to pass to the apps? If a user normally launches the app with a desktop shortcut, look at the properties of the shortcut.
Lastly, the apps that you are trying to launch are installed locally, right? If not, there are restrictions to launching .net apps over the network (assuming what you are attempting to launch are .net apps).
-
June 13th, 2014, 12:22 PM
#7
Re: ProcessStart As Current Logged In User - Need Assistance
Might want to tell us the OS that has the problem as well.
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
|