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
Related
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.
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.
I have a C# console application that runs nightly from a Scheduled Task to perform some maintenance. The application also displays a Form as a splash screen informing anyone on the system that the application is running, and shows the status.
To run the application with the correct permissions I need to run the Scheduled Task as another user. When I do this, however, the application runs but the splash screen is not visible to the logged in users.
I understand the issue but am not sure how to work around it. Is there a way to launch a Form for another user? Alternatively, is there a way to display a Form as a notification to all logged in users, similar to a 'Windows is shutting down' message?
Thanks for the ideas.
Transform your application to a service that will run all the time in "kernel mode", independently from logged on users. Then create a small client app that will run in "user mode" all the time user is logged on (one instance per each user). Use interprocess communication to send a "signal" from server (service app) to each client (user app).
You could write another small application, and put it in the All Users startup folder. This app runs when the user logs on, then sits, invisibly (or in the tray area) and watches for specific triggers that indicate that your first app is about to run. When it sees them, it launches the splash screen.
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"