Subject: How to auto. Start App As User on Server?
Posted By: BrianWren Post Date: 4/18/2008 11:55:54 AM
I have an app, DFC.EXE, which is on a “Windows Server 2003” server, and is used by an internet app on that server.

I want DFC to be running anytime the server (by which I mean the machine throuhgout this question, not the internet server) is running.  Additionally, I want it running under a specific user account.

How can this be done?

Reply By: gbianchi Reply Date: 4/18/2008 12:23:14 PM
HI there..

can you clarify a little?

You have PC A (server) with dfc.exe
You have PC B (client) that conects to a web page (or something similar) via internet

Is this correct?

And you want to execute something on A every time B starts under some account?

Is this some kind of key logger or something similar?

HTH

Gonzalo

===========================================================
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
===========================================================
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
===========================================================
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles/Classics-Week-I-Hate-You.aspx
===========================================================
Reply By: BrianWren Reply Date: 4/18/2008 12:33:38 PM
DFC runs constantly on the server with the inet server.  DFC sleeps for 5 seconds, wakes up and looks in a certain location on the server for a data file.  If not found, go back to sleep.  Repeat.
If the file is found, get the parameters out of it, and create an output file from the data.
Check for another file; if none, go back to sleep.

Separately, on the box, the internet app can write one of those data files that DFC looks for, and can find the resultant output file.  The Inet app has no additional contact with DFC.

Better?
Reply By: gbianchi Reply Date: 4/18/2008 12:40:50 PM
Quick idea, can you just put DFC into the registry under that user account so it start every time that particular user log in?

Or just start it with windows (under any account) and check what user log in and if it not the rigth one finished it? (no clue on how to know what user log in.)

HTH

Gonzalo

===========================================================
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
===========================================================
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
===========================================================
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles/Classics-Week-I-Hate-You.aspx
===========================================================
Reply By: BrianWren Reply Date: 4/18/2008 12:45:37 PM
I need this app to run as a specific user (a local account on the server) when the box is started, even when no one is logged on.  (Remember, this is a server, not a workstation.)
Reply By: gbianchi Reply Date: 4/18/2008 12:49:30 PM
Then I'm out, I don't know how to run something before you are logged in (but for sure you can). Can you just install it at a service? services has permission.

HTH

Gonzalo

===========================================================
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
===========================================================
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
===========================================================
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles/Classics-Week-I-Hate-You.aspx
===========================================================
Reply By: BrianWren Reply Date: 4/18/2008 1:01:57 PM
Yeah, there's a way to run an non-service as a service by using the wrapper “SRVANY.EXE,” installed as a service with the name you chose (let’s say running 123.exe as "TheGoob":  INSTSRV TheGoob c:\tools\srvany.exe).

After installing the srvany with the name you like, you have to go into the registry and set up "TheGoob" with the particulars of 123.exe—path, name, etc.—and set up the service through Control Panel for the account that it is to use, and whether it is to be automatic, manual, etc.

This is all very complex.  I'm hoping there is a vastly simpler way to do this...
Reply By: gbianchi Reply Date: 4/18/2008 1:10:08 PM
No clue on a simple way, sorry to not be more helpfull.

Well I have an insane idea. What if you modify the inet app so when IIS start and you have the app loading event (at least in asp) you call up the exe, and you put the permitions to the exe file?

HTH

Gonzalo

===========================================================
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
===========================================================
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
===========================================================
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles/Classics-Week-I-Hate-You.aspx
===========================================================
Reply By: woodyz Reply Date: 4/23/2008 4:31:29 PM
Hello Brian,

You could try using the Scheduled Task Wizard that is available off of the Control Panel.
This will allow you to start up the app and set the account.

No guarantee that this will do what you want, but it should give you a fun half hour figuring out if it does.

What you really want is a windows service - which is a lot of work and hassle to do in VB6, and which is also not very stable using VB6 no matter how you approach it.  The next best thing is to write your service in C# or VB.NET - in which case it is very easy and will work well.  VB6 was never intended to do this sort of thing, and while VB6 is very powerful and very easy in a lot of ways, it does have it's limitations.

Cheers...

Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
My blog... please visit
Reply By: BrianWren Reply Date: 4/25/2008 4:40:18 PM
In fact, that is exactly what I did.  That method allows you to specify the user account that the app will run under.  One of the schedule options (along with every hour, every day, etc.) is on startup.  Perfect.

I was trying to free up the time to come back here and post that, but...

I did start to try to run this in the RunAsAny.exe wrapper, but it all just got too complex.

Unfortunately I am under extremely severe restrictions on creating a new gizmo.  We are under an interim Authority To Operate on the network, and cannot change anything until it becomes the real deal, rather than interim...
Reply By: woodyz Reply Date: 4/28/2008 9:48:28 AM
The Task Scheduler does the things you were asking, but an application run this way isn't as robust as a Windows service - particularly regarding unattended operation, which is really the crux of what you are trying to do.  It's a good temporary work-around, but I'd make it very clear via documentation and emails that this should not be considered a permanent solution.

Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
My blog... please visit
Reply By: BrianWren Reply Date: 4/29/2008 1:53:58 PM
What are the pitfalls with this approach?
Reply By: woodyz Reply Date: 4/29/2008 5:03:40 PM
One important issue is if the app crashes there is no mechanism for restarting it.  A service can be automatically restarted, or have other actions taken, such as rebooting the computer or running a specific file for logging, sending emails, running diagnostics, etc.

There are administration tools for checking the status of windows services, as well as for doing things such as starting and stopping services remotely, and taking care of various logging requirements.

Also, it is much harder for a user to accidently stop a service.  This is a problem only in cases where a user might be logged on to a system.  The app you are discussing would show up in the task manager and if it has a user interface, it could be showing on the screen.  The user could accidently or purposefully shut down the app.

There are other issues as well.  Essentially it all comes down to robustness of the solution.  





Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
My blog... please visit

Go to topic 70961

Return to index page 1