Creating simple scheduled task by batch or vbs... Or other

Hi and thanks for looking,
We are using (still) windows 2000. I need to find a way of creating a batch file or script to create 2 scheduled tasks, On each of the computer that its run on..
Each of the tasks needs to be created and run under the local admin account on the pc in each case the password is the same.. eg "Password"
The local acocunt is always %computername%\AdminNT
eg when I create the tasks manual I have used "computer1\AdminNT"  and "Password"

The commands are simple c:\winnt\system32\shutdown.exe /l /r     at 19:00
And c:\winnt\system32\shutdown2.exe -s shutdown -c    at 20:00

I have sorted how to push it an run on each pc. I was planning on using schtasks.exe for the above problem, but as we are still in the dark ages i cant..

thanks agian.
LVL 1
scorpioukAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SteveGTRCommented:
You can use the at command to do this on remote machines.

Type at /? for more information.
0
scorpioukAuthor Commented:
The pc's wont be on the network all the time.

Thanks 4 the reply tho.
0
SteveGTRCommented:
When the computers are on the network you can run at from another machine to schedule the tasks? If they are permanent tasks this only needs to be done once.

If the computers are part of the active directory domain you can create a startup script to install the tasks on the computers via group polices.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

WylkellCommented:
If i remember right, you can still use schtasks against windows 2000 servers, you just cant run it from a windows 2000 box itself.  could be completely wrong on that though, but worth testing if you've got a client you can send the job creations from.
0
scorpioukAuthor Commented:
I can, the reason i want for a script was that shutdown.exe and shutdown2.exe need to be copied over first. replacing the MS one....

Any easy to follow expamples of AT commands?
are this created tasks visable in the task schedualer ?
0
WylkellCommented:
There is a bunch of documentation for at out there, but here is the one i've used in the past:
http://www.ss64.com/nt/at.html

tasks created by AT are visible in task scheduler but i think they are un-editable via the GUI (greyed out)
0
scorpioukAuthor Commented:
Ok.. thanks all.. i have looked at the above link.... I came up with :
AT.exe 19:00 /EVERY:m,t,w,th,f c:\winnt\system32\shutdown.exe /l/r

for what i need.. But I still need to get it to run under the local acocunt...
 
0
scorpioukAuthor Commented:
Really need this to work.....
0
matrixnzCommented:
Hi scorpiouk

Download and install AutoIT http://www.autoitscript.com/autoit3/ s a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.

Copy and Paste the Attached Code into Notepad or into Scite (part of AutoIT)

Save the file as scheduled.au3
Right Click the file , Select compile to EXE, then just run it.

You may need to check the commandline string, it should work, but I don't have a Windows 2000 Box around to verify.

Cheers


#NoTrayIcon
 
If Not IsAdmin() Then ; Checks if user has Admin rights or not
	RunAsSet('Administrator', @ComputerName, 'Password', 0) ; Runas Computername\Administrator with the Password: Password
EndIf
 
RunWait('AT.exe 19:00 /EVERY:m,t,w,th,f ' & @SystemDir & '\shutdown.exe /l/r', @SystemDir, @SW_HIDE) ; Run the command specified, Working Directory System32 folder, Hide the Command Window when executing
 
RunAsSet() ; Resets the Runas back to the logged on user

Open in new window

0
WylkellCommented:
With regards to AT.exe, it runs as the local system account and i dont think you can get it to run as anything else (not with AT.exe or WMI).  I would think this would be fine for kicking off a reboot though since local system should have permission to do that.  If you absolutely have to have the scheduled tasks run as a specific user, you're going to have to fall back on schtasks.exe from a single XP workstation or 2003 server pushing to all of your 2000 servers (once it's scheduled on the servers, you'll be fine).  That or pick up a 3rd party utility for all your boxes (as illustrated above).

There might be other, more "juryrigged" solutions available but i dont have one off the cuff.  Hope that helps.
0
scorpioukAuthor Commented:
matrixnz Thanks for the reply, that tool you mention looks like it could have many uses for me...

I have a few question tho....
RunWait - Is this just wating for the previous command to end first?

Many of the users will have admin acocunts, but I want it always to run under the local account. So if i drop If  "Not IsAdmin() " and the assosisated Then and Endif
Leaving the line RunAsSet...... It will always run under the account I specify in the code?

Thanks..
dave

0
matrixnzCommented:
Hi scorpiouk

Q1. RunWait - Is this just wating for the previous command to end first?
A1. Actually it tells it to run the current command and wait for it to complete before going to the next line, very much like batch "Start /wait" you probably could just use Run(....

Q2. Many of the users will have admin acocunts, but I want it always to run under the local account. So if i drop If  "Not IsAdmin() " and the assosisated Then and Endif Leaving the line RunAsSet...... It will always run under the account I specify in the code?
A2. That's correct, code attached below.

Cheers
#NoTrayIcon
 
RunAsSet('Administrator', @ComputerName, 'Password', 0) ; Runas Computername\Administrator with the Password: Password
 
Run('AT.exe 19:00 /EVERY:m,t,w,th,f ' & @SystemDir & '\shutdown.exe /l/r', @SystemDir, @SW_HIDE) ; Run the command specified, Working Directory System32 folder, Hide the Command Window when executing
 
RunAsSet() ; Resets the Runas back to the logged on user

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
scorpioukAuthor Commented:
Thanks will  test monday and let you know.
0
scorpioukAuthor Commented:
Thanks.. Just want I needed.. Few local issues but all sorted now
Thnaks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.