Solved

request vbs script to run cleandisk without user intervention

Posted on 2004-07-30
7
1,000 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

760 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

22 Experts available now in Live!

Get 1:1 Help Now