how to start applications when the system starts?

T

Tomasz Chmielewski

I wrote a little utility that runs in the background, and I would like
to write an installer for it. Writing an installer is not a problem.

I would like to start this application each time when the system starts
(it does some simple tasks, and then quits).

In Windows XP it is generally easy, as I can add application starting
with command line schtasks.exe.
In Windows 2000 there is no such equivalent.


I know I can start a service using srvany.exe, but it means that if
someone wants to use this utility, he/she has to download srvany.exe,
and it would just be too much trouble.
Besides, I don't need to run it as a service, as the utility itself only
has to be started, and it does some tasks and quits (so, why waste
resources for a service).


Do you have any suggestions how can I start an application each time the
system starts?
 
D

Dave Patrick

Maybe this helps.

http://support.microsoft.com/default.aspx?scid=kb;[LN];243486

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
|I wrote a little utility that runs in the background, and I would like
| to write an installer for it. Writing an installer is not a problem.
|
| I would like to start this application each time when the system starts
| (it does some simple tasks, and then quits).
|
| In Windows XP it is generally easy, as I can add application starting
| with command line schtasks.exe.
| In Windows 2000 there is no such equivalent.
|
|
| I know I can start a service using srvany.exe, but it means that if
| someone wants to use this utility, he/she has to download srvany.exe,
| and it would just be too much trouble.
| Besides, I don't need to run it as a service, as the utility itself only
| has to be started, and it does some tasks and quits (so, why waste
| resources for a service).
|
|
| Do you have any suggestions how can I start an application each time the
| system starts?
|
|
| --
| Tomek
 
3

3c273

Add an entry to this key in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Louis
 
T

Tomasz Chmielewski

3c273 said:
Add an entry to this key in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

But then it starts as a user who just logged in (so, if user Joe logged
in, it will be started with permissions of user Joe).

I want to start it either as Administrator or SYSTEM, and not when
someone loggs in, but when computer starts (so, even if noone logged in).
 
A

Art

But then it starts as a user who just logged in (so, if user Joe logged
in, it will be started with permissions of user Joe).

I want to start it either as Administrator or SYSTEM, and not when
someone loggs in, but when computer starts (so, even if noone logged in).

You come across as a legit guy with a legit question. So please don't
take my remarks in the wrong way.

Seems to me you're asking how to break the security model. I don't
know the answer, but if I did I certainly wouldn't post it since I'm
strongly anti-malware. Maybe the answer to your question lies in
reverse engineering samples of certain malicious code ... assuming
there are samples which can and do break the security model. But then
your program would likely be detected heuristically by antivirus
products ... and wind up either as "official" malware or one of
those detections of "dangerous" commercial products.

And maybe I'm all wet :) I dunno. Maybe knowledgeable sys admins
know how to wriite scripts that get around the security model, and
this sort of thing isn't unusual. Maybe I'll learn something by
continuing to monitor this thread. The NT based OS are "new" to
me since I'm a long time user of Win 9X/ME.

Art



http://home.epix.net/~artnpeg
 
T

Tomasz Chmielewski

Art said:
You come across as a legit guy with a legit question. So please don't
take my remarks in the wrong way.

Seems to me you're asking how to break the security model. I don't
know the answer, but if I did I certainly wouldn't post it since I'm
strongly anti-malware.

No, you're completly wrong. :)

If I'd like to do something malicious, I'd ask at some h4ckerZZ forum,
not here.

I have a rather *NIX background, and there to start something with
highest permissions when the system boots is very easy: just create a
symbolic link from your application to /etc/rcX.d (i.e., your runlevel)
- of course you have to be root (system administrator) to do it.

That's it, nothing more, 2 second job, one-line command, and you can
start any application you want (for example, send you an email that the
system just booted, start a service, etc.) - and that is how easy to do
it in an installer.

I'm trying to do the same in Windows 2000, but it's so damn frustrating
:) (and Windows was supposed to be so easy in administration), I can't
do it - all that I found that I either have to:
- use GPO on a domain controller (well, it's a single computer, isn't
it, so GPO won't help me here),
- download srvany, firedaemon, configure it, register service - but here
I can't bundle these tools with my installer
- many more contradicting advices, like putting a shortcut in Startup
folder etc.
- use "local policy", and start scripts from there - why not, but what,
do I have to write an installer which says "Hi, this is installer, to
install this app click here and there and then type that..."? :)

So, how can I start a simple script/program on a boot time in Windows 2000?
It would be best if I could schedule it from a command line, like it is
in schtasks.exe in Windows XP.
 
A

Art

No, you're completly wrong. :)

We'll see. I've posed the issue on a private list to get expert
opinion on the security model breaking aspect. I'll eventually
find out if there is any malicious code capable of doing what
you want to do, and whether or not it's practical, and whether
or not it's a sensible thing for a legit coder to attempt on the
NT based OS.

Art

http://home.epix.net/~artnpeg
 
T

Tomasz Chmielewski

Bob said:
Set up Scheduled Task, for "When my computer starts". (No big deal)

Yeah but that's practical with Windows XP, where there is a command line
schtasks.exe (Scheduled Task) for adding tasks - so I can add a task
with such a command:

schtasks /create /tn wTASKNAME /tr "%programfiles%\tools\command.bat"
/sc beimstart /ru SYSTEM


There are some minor troubles with that, like "/sc beimstart", which is
valid for German only, and which in English won't work, but has to be
"/sc onstart", and is different in different language versions of Windows.
But it's a Windows-specific problem with many tools, and we have to live
with that.


With Windows 2000 there is no command-line schtasks (Scheduled Task);
there is only a GUI version - so I can't use it from within an installer.

So in Windows 2000, I can't add a program/script to start when system
starts, and, contrary to what you write, it is a *big* deal.
 
T

Tomasz Chmielewski

Art said:
We'll see. I've posed the issue on a private list to get expert
opinion on the security model breaking aspect. I'll eventually
find out if there is any malicious code capable of doing what
you want to do, and whether or not it's practical, and whether
or not it's a sensible thing for a legit coder to attempt on the
NT based OS.

Gee, it looks like you've read to many spy books...

You can use a hammer to build a house; you can use it to hit someone in
head, too.


I'm asking for an easy thing to do, at least under Windows XP/2003/*NIX,
but as it appears, not on Windows 2000.
 
B

Bob I

Then perhaps with those additional constraints you want to set it as a
service. see "servany"
 
A

Art

With Windows 2000 there is no command-line schtasks (Scheduled Task);
there is only a GUI version - so I can't use it from within an installer.

So in Windows 2000, I can't add a program/script to start when system
starts, and, contrary to what you write, it is a *big* deal.

In regard to my query on a private list, one fellow responded that it
seems you need to develop a Windows service. He said it doesn't
involve a break in the security model at all, as I had thought it
might.

Art

http://home.epix.net/~artnpeg
 
T

Tomasz Chmielewski

Bob said:
Then perhaps with those additional constraints you want to set it as a
service. see "servany"

It looks like you're not reading what I write :))

It's called "srvany", not "servany".

I don't want to use srvany, for several reasons:

1) it creates a service, so something that runs all the time.
The utility I want to write an installer for (see http://wpkg.org -
WPKG) only starts once, does its job, and then quits.
There is absolutely no reason to keep a service running (which means
less resources), when there is no need to do so.

2) I would have to bundle srvany.exe with my installer, as it is not a
standard utility - it is only in Resource Kit.
The Resource Kit is only available for those having a valid Windows license.
So if I offer my tool/installer for download, and this is downloaded by
someone without a valid Windows licence, I'm in legal trouble with
Microsoft.
 
T

Tomasz Chmielewski

Art said:
In regard to my query on a private list, one fellow responded that it
seems you need to develop a Windows service. He said it doesn't
involve a break in the security model at all, as I had thought it
might.

See my response to "Bob I" why I don't want to start it as a service (at
least by using srvany).
If there are some other ways to start a service, I'd be glad to know.
 
A

Art

See my response to "Bob I" why I don't want to start it as a service (at
least by using srvany).
If there are some other ways to start a service, I'd be glad to know.

I've given this guy the names of the n.g. and Subject. And told him
you're tearing your hair out. Hope he or someone else can help.

Art

http://home.epix.net/~artnpeg
 
G

GO

What about the "at" command? Is it absolutely necessary to have your
application run only during startup? You can schedule your program using
"at" but I don't think there is a way to tell it run at bootup.


Greg
 
T

Tomasz Chmielewski

GO said:
What about the "at" command? Is it absolutely necessary to have your
application run only during startup? You can schedule your program using
"at" but I don't think there is a way to tell it run at bootup.

yes, I was thinking about the "at", too, but unfortunately it seems
impossible to schedule a task at a boot time with it - which is just
necessary to me.
 
M

Michael Bednarek

I wrote a little utility that runs in the background, and I would like
to write an installer for it. Writing an installer is not a problem.

I would like to start this application each time when the system starts
(it does some simple tasks, and then quits).

In Windows XP it is generally easy, as I can add application starting
with command line schtasks.exe.
In Windows 2000 there is no such equivalent.

There's JT.EXE from the Resource Kit; you could (possibly) include that
in your installer and have the installer run a JT command line which
will create a scheduled job "/CTJ Type = AtStartup". AFAIK JT is not
language sensitive.

[snip]
Do you have any suggestions how can I start an application each time the
system starts?

Or you could create such a scheduled job (.job) on your system, include
that file in your installer and place it in "%windir%\Tasks\" - that
will only work if the parameters of the job are fixed and known.
 
T

Tomasz Chmielewski

Michael said:
There's JT.EXE from the Resource Kit; you could (possibly) include that
in your installer and have the installer run a JT command line which
will create a scheduled job "/CTJ Type = AtStartup". AFAIK JT is not
language sensitive.

I'm not sure if it is legally correct - utilities from the Resource Kit
are for those having a valid Windows license; if I offer my tool for
download, and it's downloaded by someone without a valid license, I may
be in legal trouble with Microsoft?

[snip]
Do you have any suggestions how can I start an application each time the
system starts?


Or you could create such a scheduled job (.job) on your system, include
that file in your installer and place it in "%windir%\Tasks\" - that
will only work if the parameters of the job are fixed and known.

This could work, but I'm afraid it will not.

I could of course fix the task to be in %programfiles%\somefolder\ - and
point a .job to execute it.


But a .job file only contains part of needed information; other parts
are stored somewhere in the registry.

So when the .job file is copied to another computer, one has to reset a
username (and perhaps a password).
I might try if it will work with a password-less user (SYSTEM), without
resetting a username? This would be great, as it would be an answer to
my question!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top