Solved

request vbs script to run cleandisk without user intervention

Posted on 2004-07-30
7
1,005 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

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…
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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