Creating Windows® Tasks to Run as Adminstrator


Of course, with all howtos, I assume no responsibility for anything bad that happens if you follow the advice contained in these documents. I'm merely trying to be helpful, by conveying what worked for me. By implementing my advice, you are implicitly accepting this disclaimer. Comments are appreciated, though.


So we all know that the multi-user properties of the Windows® OS's are heinous.  Luckily,
with about 10x more effort than on Un*x systems, most of the same things can still
be done.  One such thing that any decent Windows® workstation should have done is
regular, automated backups.  I was always amazed when working at big companies
with dedicated sysadmins that their solution was usually just to tell people to keep all
their important stuff on shared network drives, that are backed up.  That's fine, except
you can't do that with everything, such as program data that must be installed locally.
While that stuff often can be recovered from CD-ROM if lost, the configuration of
a lot of software takes a lot of time (=money) and there's no good reason to lose
that and have to recreate it at all in case of a disk failure, or other error that you want
to recover from.

So, I decided to create regular automated backups for all my machines.  The Backup
tool that comes with all major Windows® versions should be sufficient for most people's
needs.  The bigger problem is getting to schedule that program to run by itself, in an
autonomous way, at a time of day that doesn't impede work.  Oh, and by the way,
there's no reason a person should have to log off of their (non-Administrator) account
at the end of every day just to allow this process to run, and backup anything we
want, whether or not the casual user has permission to access all the files we need to
backup.

So, what we want to do is schedule the backup job to run as Administrator, and be
runnable even if another lowly user is logged on.

Clarification

This howto is written with Windows 2000® in mind.  Not sure what differences exist in
other flavors of OS.

Steps

All these steps require Administrator priveledges to setup.  After that, the job should
be runnable no matter who's logged on.

1) First, you need to define a backup job with the graphical Backup tool that ships
with the OS.  If it's not showing up in Start Menu -> Accessories -> System Tools,
then try going into the Control Panel and installing new Windows® Components.  It
should be in there somewhere.

2) In Backup, define a job with all the backup parameters you want (tape or file,
time to run, wake computer settings, etc.).  Then, go to Job -> Save Selections As
and save the job description file (.bks) somewhere that you'll remember it.

3) Go thru and actually schedule a backup job to run. I would just use the Backup
Wizard for this. When you get thru all the choices, you should see a calendar that
reflects the new job you've added.



Then, when you're done with that, you should be able to quit the Backup tool and open the
Scheduled Tasks window from the Accesories -> System Tools menu of the Start Menu. You
should see your new backup job there.  You may be thinking, "Ok that's it .. I'm done!".  But alas, no.
The way the tool creates the task, it will not be able to run when another user is logged
on.  So what you need to do, is open the properties for your task by right-clicking it
and selecting Properties.  You'll see something like this:




4) What you then need to do is record the command line that the task is going to use.
Copy it from the Run: field and paste it into a text file.  I like to actually create a
runnable command file, and give it a .cmd extension.  So, create a new file
called my_backup.cmd, store it somewhere meaningful, and paste the task command
line into it.  You'll notice the command line references the backup job file you defined
above, which holds the proper settings.

One another important thing you might choose to do in this command file is to map network drives
if you're choosing to save backup data (the .bkf file) to a network location, rather than a tape
device. For this, use the net command line utility. One caveat is that this command
needs to function regardless of whoever is logged on to the computer when the task is run.
Unfortunately, with some implementations of network shared drives, it may only be possible for one
user per computer to map to a given network server. This is the case with my Samba installation.
So, if your network drive requires access control (username and password), you have to figure out
what identity you want to use when users, and the backup task connect to drives. I'm not
claiming to be able to solve that problem for you here, because there are a lot of different ways
to handle this, but you should know that it may be an issue for network file share backup locations.

5) Next, you need to create a new task using an alternate method.  This will be via the
AT command at the DOS command line.  Open up a command window, and type:

>>AT 02:00 /every:Monday "C:\tools\my_backup.cmd"
assuming this is where you stored the my_backup.cmd file.  This will create a system
task, which is a little different that what was created via the Backup GUI earlier.

If this worked, you should see something like this in the command window:
Added a new job with job ID = 1
6)  Now, you should be able to go back to the Scheduled Tasks window and see the
AT task you just created.  Notice it's got a slightly different icon than the tasks created
from the Backup GUI.  From here on out, you can edit all the task settings via the
Schedule Tasks GUI, which is much easier. This includes renaming the task, changes it's command
line, scheduling it for a totally different time, or whatever. The key was to create the task from
the command line with AT.  



7) To finalize your new backup task, you should set it to run as
COMPUTERNAME\Administrator, and be sure to enter the password.  I have read some
things that suggest that changing various settings will cause the software to "lose" the
password.  Therefore, I always choose to Set Password again after making any changes
to the task.  I suppose this interface allows you to define a password that's specific to the
task, but that doesn't make a ton of sense to me.  I simply use the normal Administrator
password.  This works for me.  You can also set permissions on the task so that other
users can run it, or maybe just see it (read-only) so they can at least know when the job
is supposed to run next.

8) Log off of administrator and you should be good to go.  Note that if you use power saver
features on this computer, you can only let the computer go into Standby at night (not off),
and you must explicitly set the task to wake the computer to run.  



Otherwise, the computer will just sleep thru its backup job everynight, and leave you
dissapointed when you finally need to access your non-existent backup data.

As a final note, double check this process until you're comfortable that it's running reliably.
This is much more fragile than a Un*x cronjob.  Also, remember that if you change the
Administrator password on the machine, you have to manually update the password for
each of your tasks .. uuggh!

Happy tasking!

Of course, "Windows is a registered trademark of Microsoft Corporation in the United States and other countries."

powered by Debian

Copyright ©2003-2016 Enscand, Inc.
All Rights Reserved

Modified February 21, 2016
Privacy
Security
Environment