Solved

request vbs script to run cleandisk without user intervention

Posted on 2004-07-30
7
1,001 Views
Last Modified: 2010-04-13
I would run the utility cleandisk from the command line, so I can put it in the scheduler.  vbs looks good, but I do not know how to do the checkboxes, which I want all turned on.
0
Comment
Question by:astar666
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:Nabeeh ElDardery
ID: 11685463
what about if you can run this script after user logs on (i hope understood u)
0
 

Author Comment

by:astar666
ID: 11685587
Yah, that is fine.  This workstation is approximately always logged on, and anyway, in win2k, the scheduler asks for the user and password it is supposed to run as, so I expect the scheduler can do sort of a login on its own.  Background is I asked about way to do defrag from the command line and someone kindly gave me a whole windows shell script, which works well enough.  I am a programmer but have not worked with windows shell script.  Reading the tutorials, I seem to be missing something in my head to write a windows shell script for cleandisk, because of the checkboxes.  Maybe it needs a lot of tabs to get to the checkboxes, is what I have since decided.
0
 
LVL 17

Expert Comment

by:Eagle6990
ID: 11690305
Here is the command you are looking for to automatically run chkdsk with the /f option, and bypassing the prompt if you would like to schedule it for next reboot.


echo y | chkdsk C: /f
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 17

Expert Comment

by:Eagle6990
ID: 11690326
To create the scheduled task I would use a command line option as a login script or however else you wish to push it out.  For example, create a batch file called checkdisk.bat in your Windows directory and put in

echo y | chkdsk C: /f

Then I would push out this command to create the scheduled task.

schtasks /create /tn "Checkdisk" /sc daily /st 01:00:00 /ru system /tr "c:\windows\checkdisk.bat""
0
 

Author Comment

by:astar666
ID: 11690588
That is interesting, but not quite responsive.  The problem is that the cleandisk function is cleanmgr.exe, which takes no known command line parameters.  For instance I just tried cleanmgr /? and just got the gui.  So this is why it would seem this needs windows scripting.  On the other hand, the checkboxes issue turned out to be bogus.  Here is a windows script I have now written that seems to work:

set WshShell = CreateObject("WScript.Shell")
WshShell.Run "%SystemRoot%\System32\cleanmgr.exe"
WScript.Sleep 2000

WshShell.SendKeys "{ENTER}"
wscript.sleep 1000

While WshShell.AppActivate("Disk Cleanup for")= FALSE
  wscript.sleep 5000
Wend

wscript.sleep 1000
WshShell.SendKeys "{ENTER}"

wscript.sleep 1000
WshShell.SendKeys "{ENTER}"

While WshShell.AppActivate("Disk Cleanup for")= FALSE
      wscript.sleep 5000
Wend

In other oddies, my best understanding is that on a nfts volume, dfrg.msc performs as part of its activity, the chkdsk function.

0
 
LVL 17

Expert Comment

by:Eagle6990
ID: 11690635
Oh, I thought you meant checkdisk and not clean manager.

This is some info on scheduling cleanmgr
http://www.tweakhound.com/xp/tasks/sch_disk_cln.htm
0
 
LVL 17

Accepted Solution

by:
Eagle6990 earned 125 total points
ID: 11690636
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
If your vDisk VHD file gets deleted from the image store accidentally or on purpose, you won't be able to remove the vDisk from the PVS console. There is a known workaround that is solid.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now