views:

1134

answers:

6

Is it possible to run a windows form application or a console application under system account... Like asp.net application can run under system account by changing machine config file . This is to give more privileges to the program ...

A: 

Can't you do that by launching it from a scheduled task in Windows?

MartinHN
come again? you mean to say if i put my program under scheduled task( on user login) it will run under system login and getting all access as administrator?
Yes, you can select the execution account for the scheduled task.
MartinHN
+1  A: 

Yes. You can run any app under the system account. One technique is to launch it as a scheduled task, or by using the "at" command line utility.

Unfortunately, however, since Windows Vista, applications run in this way can't interact with the user, since they run in a different session.

This means that running a WinForms (or any kind of GUI, really) application in this way is kinda pointless. Similarly for a console app, if you want to see the output.

If it's for a one-off, you can probably live with it. Otherwise, you should be looking at creating a Windows Service, which can be configured to run under any user account (including SYSTEM). If you want to interact with it, you'll need to implement a separate app that talks to it through (e.g.) .NET remoting.

Roger Lipscombe
well i am not too familiar with scheduled task.. here its asking for username and password... I have looked into windows service... would have been solution... but the application is form based( requirements are such ) ...
+2  A: 

Two ways to get a program to run under a different user context than the one you're currently logged on as:

Use the RUNAS command

RUNAS /user:USERNAME PROGRAMNAME

Example:

RUNAS /user:YOURDOMAIN\ADMINISTRATOR NOTEPAD.EXE

This will pop open a console window asking for the password. The RUNAS command can not be given a password through the command line, it has to be typed in by the user for security reasons.

Create a shortcut to the program that runs it under different credentials

First create the shortcut, then edit the properties of it, and on the first tab, click Advanced. On the dialog that pops up, check the "Run with different credentials".

When you start the program through the shortcut, it will pop up a dialog asking for which username and password you wish the program to run under. Again you cannot store the username and password for security reasons.

If you want to create a shortcut or similar that automatically selects a new user context, then I'm afraid you need to find a tool online, unless you mean to run the program as a service or similar.

Lasse V. Karlsen
A: 

That depends on what your goal is. If you want it to run under the system account and let a user interact with it, you can't do that. If you absolutely need to do this your best bet it to create a service that handles the operations that require additional priveleges and runs as System, and the connect to that service from a GUI running as user. However, if you go this route, realize that you're creating a hole in the security boundary between what a standard user can do and what System can do so be sure you protect the connection between the GUI and the service and limit the scope of the service to only what you absolutely need it to do.

As lassevk mentions if you just need to do this once or occasionally you can use runas to run in another security context but still have an interactive GUI / console.

On the other hand, if you just want it to run unattended at a certain time, you should be able to use the task scheduler like Martin suggests.

Jon Norton
Thanks for all your very quick response... I had arrived at the similar conclusion of making a windows service...due to time constraints i was looking for a "way out"... Most of the things work pretty fine ..except those stuff that require admin rights...
+1  A: 

It sounds like you're attacking the symptom rather than the problem. What exactly does your program need to do that requires additional permissions? Maybe there's a different way of accomplishing that task without requiring any kind of elevation.

Joel Coehoorn
well the log in account is very restricted... and the application needs access to events logs and file system.. There is no other account...
Windows service is at least temporarily out of question 1. because of lack of interaction( though there is going very less user interaction, ) 2. as the application is already developed, there is no time for change...
Does it need to write or just read?
Joel Coehoorn
both... on system drive and the log in account does not have access to system drive... and event logs there is further restriction.. the program reads/writes/ create a custom log too... the client was supposed to give a separate login for program, which was changed for reason unknown,lol...
separate account for the program...
A: 

can any one help me my problem is

executing the notepad.exe at the client side well i am using asp.net c# it has to work when iis server is installed

please provide me some code for it

pleeeeeeeeeeeeeeeeee

my emailid- [email protected]

mansoor
That's not an answer to this question. You should better ask this as a new question, but don't expect people to send you anything (besides spam) per email.
sth