Solved

request vbs script to run cleandisk without user intervention

Posted on 2004-07-30
7
1,004 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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