Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help making a script to run tasks

Status
Not open for further replies.

spool

Technical User
Jan 20, 2003
262
US
hello,

I know a little about scripts but I think this is over my head.

I need to run three scheduled programs on 20 computers in our office without intervention in succession. I like to schedule it when no one is working around 3:00 AM. I was able to this with our 98 boxes but now all are XP's.

Disk Cleanup>cleanmgr.exe
Error-Checking>chkdisk.exe
Disk Defragmenter>defrag.exe

I used Scheduled Tasks to start Disk Cleanup but it needs someone to choose what drive to scan and then click OK and then click OK to delete the files. I need it to run all the way through on it's own.

I have XP machines so Error Checking can only be run after restart.

Defrag is the same as Disk Cleanup it needs someone to choose what's next to be done.

This is what I'm trying to do. First schedule Disk Cleanup to run then after it is finished restart the computer and run Error Checking after Error Checking I think it brings me back to the logon screen. So I think I will have to bypass logon so the final program Defrag can run then restart or log off to bring the system back to the logon/Welcome screen.

Now this is what I have done/tried. The script I did can get Disk Cleanup to start but I can't get past the OK button so the other OK button can be reached so the program can delete the files.

I did a script that will restart the computer. But I need checkdisk to know that it is next to run.

I got from this forum a vbscript that will run defrag completely.

I need to connect all these tasks to work in one fluid motion.

Any help would be appreciated.

spool


Don't argue with an idiot, he will bring you down to his level and beat you with his experience.
 
sorry again posted two times.

spool

Don't argue with an idiot, he will bring you down to his level and beat you with his experience.
 
Spool;

I'm doing the same thing. Here are my suggestions.

1. CleanMgr: Research the "/sageset:n" and "/sagerun:n" arguments, where "n" represents a long integer. These arguments allow you to set a configuration and run it against a drive.

2. ChkDsk: Use this command with the appropriate arguments, and then schedule a restart using the "shutdown" command, again with the appropriate arguments.

3. Defrag: Use the "defrag.exe" found under Windows/System32, again using the appropriate arguments. This executable is specifically designed for admins.

These can all be configured to run against a specific drive, and to also run under Scheduled Tasks. I've done it, and they all work great.

Because you probably need to boot for ChkDsk to run, you can't combine all of these into one script, but you can certainly schedule them to run one after the other. And at 3:00 AM, I would think it wouldn't matter if they were all programatically linked.

Hope this helps!

 
Hello,

BuckBMD, Thanks for the info. I know I can run these tasks from the command prompt. I'm trying to learn how to run scripts/batch files for these tasks.

I wrote a batch file for check disk that works for XP and 2000. And it runs through all five stages.
As we know Check Disk does not run until the system frees up the hard drive. So the computer has to be restarted.
This batch file does just that, unattended using Scheduled Tasks.


-------------------------------------------
echo y|chkdsk C: /F /R

Shutdown.exe /r /t 05
-------------------------------------------

F = Fixes errors on the disk.
R = Locates bad sectors and recovers readable information.

Shutdown:
r = restart
t = time in seconds
05 = launches a warning window saying how many seconds before restart.

Use notepad, save as, .bat.

Note: Win 2000 does not have a copy of Shutdown.exe you can get a copy from the Win 2000 resource kit or XP. C:\Windows\System32\. Drop it in C:\Winnt\System32



I posted twice so all my updates will be at this thread.
Please reply using this redirect.


Thanks, spool




Don't argue with an idiot, he will bring you down to his level and beat you with his experience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top