Windows Server 2003
1753560 Members
5991 Online
108796 Solutions
New Discussion юеВ

Re: Start a executable .EXE under a different user, every time its called

 
tibornad
Esteemed Contributor

Start a executable .EXE under a different user, every time its called

hi win board

i'm looking for a way to tell a .exe to run under a specific user account (domain) every time it is called.

i'm aware that there a manual ways to do this with the runas command or different other enhanced tool. the point for me is i need something that works without user interaction.

means i have a scheduled job which starts a HP LoadRunner component called mdrv.exe
this on a machine where no user is logged in most of the time.

therefore i need to assure that the .exe is always started under a specific user account every time it is launched.

is there a way i can directly add the user to the .exe ? i did some extended google research. found several tools to do manual runas or scripts. but nothing to edit/change the .exe without and need to rename or so.

all help is highly appreciated and points will be awarded

many thanks
4 REPLIES 4
Kase
Frequent Advisor

Re: Start a executable .EXE under a different user, every time its called

tibornad, the user account you specify under the scheduled task is the security context Windows will use when running the task at the scheduled time. This account must, of course, have all the necssary rights and permissions to perform the scripted action.

For example, in your case:
1. Create a new local account called svc_loadrunner on the server and add it to the local administrators group (thus ensuring this account has the necessary local access).
2. Create a scheduled task that fires a batch file calling mdrv.exe with the appropriate parameters using the svc_loadrunner credentials. When the task is launched, it will run under the svc_loadrunner account. I believe this should fit the scenario you have described.

Note, when creating the svc_loadrunner account, it was added to the local administrators group giving it full access to the local machine. Access should be scoped properly to avoid (as in this case) giving too much access to an account. I did in this case to simplify. Also, if you have to access network resources in your script, this would require some kind of shared directory service or synchronized workgroup credentials.
Once you have the scheduled task configured and running, you can further troubleshoot with this document: http://www.shijaz.com/windows/taskscheduler.htm
tibornad
Esteemed Contributor

Re: Start a executable .EXE under a different user, every time its called

thank you very much for your suggestions. sounds like a feasible solution for my scenario. i'll give it a try

cheers
skris
Trusted Contributor

Re: Start a executable .EXE under a different user, every time its called

Interesting!
The task scheduler would be applicable if a specific user is logged in all the time i reckon.

Have you looked up the options of running a program as a service?

You just may have to tinker with the registry a bit and you would have the following options:

1) Select the user running the prog.
2) Set dependencies
3) Set Restart tries incase if program fails to start
4) User's need not be logged in to run the service.

Here's the link:
http://support.microsoft.com/kb/137890

Cheers!
Shiva

Kase
Frequent Advisor

Re: Start a executable .EXE under a different user, every time its called

@skris: The task scheduler is a service and is capable of launching tasks without a user being logged on to the computer.