I'm writing a C# program that runs on a remote windows embedded device. it is running in admin mode.
From this program I try to open an exe, but by default, this exe is opened in the same admin session.
How can I open it as another user?
I already tried different things googled here and there, especially : Starting a process with credentials from a Windows Service.
But it still opens in the admin session.
Thanks for your suggestions.
Related
I am writing a piece of software that needs to launch another program. On the network I am using I am not an administrator and command prompt is blocked.
Will Process.Start() still work?
Will Process.Start() still work?
I can't see how an admin can prevent one process from spawning a child process. It's an essential part of Windows.
For example:
Windows Explorer runs in the user account of the currently logged-in user. In Windows 7+, selecting any folder with the mouse and pressing ctrl+enter, causes a new Windows Explorer window to appear for the selected folder in a new process! You can verify this in Task Manager
If you can do that on your computer in the selected user account, so too should your application.
Blocking the command prompt will not stop Process.Start() from working.
How ever if an administrator has gone to the trouble to block the command prompt they may have implemented a group policy to only allow certain programs to be run.
See this link for details http://www.nextofwindows.com/how-to-use-local-group-policy-whitelist-certain-programs-in-windows-7
You may not be able to start any programs that are not on this "whitelist".
The easiest way to find out is to just try it yourself, but if you are able to run your own custom program that calls Process.Start(), the fact that your program runs, probably means the administrator has not set up such group policy.
Short version: How do I display my Winforms application to users remotely logging on in a Windows Server environment?
Background: I am deploying a C# Winforms application to a number of different Windows servers, some 2008 and some 2012. When a user logs on to one of these servers through remote desktop, I want the form to show up on the user's screen immediately. The program itself is a basic form which writes to the Windows Event Log in the Application section.
What works so far: I have successfully gotten the program to launch on a Windows Server 2008 machine when a user remotely logs on. I did this by creating a scheduled task which was triggered by user logon. Here's the batch file that did it:
SCHTASKS /Create /TN "MyLogonTask" /TR "C:\Path\To\Program.exe" /SC ONLOGON /IT
Here's the problem: When a user other than the one who created the task logs on, the form does not show up for them. To be more specific, the task does start, but the form only shows up for the user who created the task, RATHER THAN the user who actually logged on.
What I've done: I've tried changing the settings around inside the task, as well as launching the program with and without admin privileges. Also, I did try removing and recreating the task with different users, and every time the form only launched for the user who created the scheduled task. So far I have not had any luck with getting the program to display for the correct users.
You could place a shortcut in the StartUp folder. The location of this folder might vary by OS, but on 2012 R2, the user one is here:
C:\Users\[USER]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
and the machine one is here:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
I have a exe of windows form application which is copied in AppData folder of each logged in user. Currenly that exe gets started after user log in but it takes lot of time to start. So I am thinking of developing a windows service which will invoke that exe as soon as the User logs in. I want to start that exe separately for each logged in user.
Am I going in right direction developing a windows service if yes please tell me how to do that else what is ideal way to do this?
As far as I know, the service can only interact with the default desktop.
In a corporate network based on Active Directory, you would use a group policy to run the exe for each user.
On a stand-alone PC, you could set the startup programs for each user.
I have a single form application which checks user states continuously via timer. I want to start the same .exe by using process.start("C:\inetpub\wwwroot\mywebapp\Checker\checker.exe") in Web Application. The exe appears in System processes list (not appear in application list in Windows Task Manager) after the code executed but it does nothing. It is not changing the user states nor sending Data to Database. But when I start same .exe manually on double clicking, it start working and it also appears in Windows Task Manager Application list and in Process Lists. The .exe is made with C#.Net and is executed file of C# windows application.
When launched by IIS the process will run under the account that started it, which will be the w3wp processes that is running your web application. Because this isn't your account it won't show up in task manager until you select the "show processes from all users" option. When you run it via a double click it is running under your account, so will be visible.
If the changes and database access rely on using your account to gain access then this wont work when it runs from within IIS. For example, if your database connection is done using "Windows Authentication" then it will try to log in as the IIS account, which is unlikely to work.
To fix this you can launch the processes by specifying a username/password in the ProcessStartInfo structure. However, this will require you to embed your password somewhere, which may not be desirable. Alternativly look at changing the database connection string so that you specify the logon credentials explicitly.
can we invoke exe of application(made in .net) on remote server using local machine.
we have full credentail on all machine to execute process.
how can we achive that ?its require to open GUI on remote machine.
we tried using WMI/.dat file invoke but all opens process on Task Manager & could not lunch GUI..
anyone have idea to accomplish same??
You can use psexec for this.
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
At one point in time, you could write a Windows Service, run it under the local system account, and allow it to interact with the desktop. However, this will only work on Windows XP. Vista (and I assume Windows 7) show the UAC prompt first, which is annoying and sometimes only shows up on the taskbar until it's clicked.
We got around this by writing a WinForms app that had no visibility on its own, but this app watches for a trigger. When the trigger occurs, the program then launches the appropriate exe.
For example, the trigger may specify to open up a web page on our intra net. The program uses the System.Diagnostics.Process.tart() to launch the web page in the default browser.
The trigger can be one of many things... The exe can poll a database, web service, etc. The exe can host a WCF host use remoting, or it could use a FileSystemWatcher.
The most complicated part of writing such an app is figuring out the appropriate trigger. Launching the app is trivial using the System.Diagnostics.Process.
For our situation, we set the program up to just launch when Windows starts, USG a registry setting.
Use PsExec tools
with -i switch
Like
psexec \\remotecomputer -u username -p password -i 2 "your exe loacation"