Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What would be the DOS commands to disable all non-Microsoft Services, Startups, and my DSL connection, just before I run Check Disk and Defrag in automated bat files?
What would be the DOS commands to later re-enable them?

I currently have a separate bat file for Check Disk and for Defrag. Is it possible to combine these into one so they run consecutively?
As it is right now, I just leave a little time in between them.

I never tried it, but would the Defrag bat file automatically delay itself, and then run, if it were scheduled to run but Check Disk was still going?

Below is what I am currently doing.

AUTOMATED CHECK DISK AND DEFRAG

I have two 160 GB drives, C: and D:
I leave my computer in Standby, Scheduled Tasks wakes it up to run the following once per month:
Check Disk at 1 am (1 hr 25 min per drive)
Defrag at 5 am (8 minutes for both drives)
I then take a look at the results in the morning

This is what is in my two bat files ... put this in a text file, and then change the .txt extension to .bat \ Set them to run in Scheduled Tasks.
Need a password in your user account, and that password used in Scheduled Tasks.

Check Disk.bat
ECHO y|CHKDSK D: /X/R
ECHO y|CHKDSK C: /R
SHUTDOWN -f -r -t 00

Defrag.bat
C:\WINDOWS\system32\defrag.exe d: -v>"c:\Documents and Settings\Administrator\Desktop\defrag d.txt"
C:\WINDOWS\system32\defrag.exe c: -v>"c:\Documents and Settings\Administrator\Desktop\defrag c.txt"

This used to work fine, then something happened, I do not know what, I started getting these errors:

5/18/10 it did not Defrag C:, got exit code of 0x6

9/21/10 It did not Check Disk D:, cannot lock current drive, volume dismounted, all opened handles to this volume are now invalid
AVG Free is preventing it? Where is the setting in AVG Free to let things run? I do not know.

CHECK DISK BAT FILE NOTES
Echo y means to reply "y" for yes to the questions.
It does C: first then D:
I found that if I do not use the Force Shutdown parameter, something did not work
Event Viewer \ Application \ Winlogon \ look here to verify no bad sectors

DEFRAG BAT FILE NOTES
The -v parameter gives you verbose output, then you can look at your pagefile to verify that it is in one fragment
View the verbose output \ Pagefile Total fragments = 1? . . . 70 MB and 2.93GB
If not, show hidden files, delete the pagefile, Restart, and it makes a new one in one fragment
Computer Management \ Storage \ Disk Management \ Healthy? . . . drive needs 15% minimum free to defrag

OTHER NOTES
Prior to Check Disk and Defrag, the night before I deFrenzy my fonts, use WinDirStat to see if I want to delete any big files, and run CCleaner
I use calendar software so I do not forget
http://www.sdsoftware.org/default.asp?id=5936
http://windirstat.info/
http://www.piriform.com/download
http://calendarscope.com/

HERE IS HOW I GOT IT TO WORK

The night before, I disabled non-Microsoft Services, Startups, and my DSL connection (I use calendar software so I do not forget)
Start \ Run \ msconfig \ Services tab \ [check] Hide All Microsoft Services \ Disable all . . . Startup tab \ Disable All
Control Panel \ Network Connections \ right-click and disable DSL - since my AVG Free is disabled ... cannot hurt
Power off the monitor . . . then Check Disk and Defrag run successfully!

MYSTERIES

If I run Check Disk from Scheduled Tasks ...
Right-click \ Run, and watch it - hit the enter key to cancel so you do not have to sit through Check Disk, you just want to see what it is going to do
It does C: first then D:
It looks like Check Disk gives some kind of error message in the DOS window, but it goes too fast - you cannot read it, and there is no switch to do verbose output like Defrag

9/24/10 both Check Disk and Defrag worked
computer was in Standby, but froze when brought out - try going into Standby, bring it back out, re-enable Services, Startups, and DSL, then do a Restart?
Did not work, it was frozen again, have to do a Restart without re-enabling anything first, then I can re-enable Services, Startups, and DSL

PAGEFILE / VIRTUAL MEMORY NOTES

I have 2 GB of memory
I read that the computer can run faster if it can utilize another separate drive for the pagefile, since the OS is on C:
Control Panel \ System \ Advanced \ Performance \ Settings \ Advanced \ Virtual Memory \ Change \
Custom size (make Initial and Max the same) \ Set

Initially, I put what I think is a standard size, small amount on C:, 16 MB ... (I had a 486 with this amount of RAM a while back)
... Some programs expect to see some on C:, so you need some there ... the balance to D:, 3054
16 MB seemed to work fine, but there were some occasional glitches ... maybe more on C: would be an improvement

9/26/10 computer froze up trying to do multiple things with 170 on C: and 2900 on D:
I think it was better with 16 on C: and 3054 on D:

I notice it says 2MB is the minimum, 3070 is the recommended - so I will try that: 2 MB on C: and 3068 MB on D:
after a Restart, it let me open up Start, and an Excel spreadsheet, right away ... it did not do that before, it used to get stuck on opening Start ... seems more responsive
It says I only have 3068 total allocated though . . . ok, so I will leave the 2 MB on C: and set 3070 MB on D:
Mouse is stuck when bringing it out of Standby, did not do that so much before with 16 MB on C:

Current experiment: try 70 MB on C: and 3000 MB on D: (2.93 GB) ... 3000 MB is a nice number, put oddball amount on C:
10/12/10 Seems to be working fine.
Posted

C++
More pieces to the puzzle - Summarized

*****************************************************************

How to delete the pagefile and re-create so it is only one fragment
http://www.windowsdevcenter.com/pub/a/windows/2004/11/23/defrag_pagefile.html

To defragment the pagefile, first remove the pagefile, then defragment the machine, and finally recreate the pagefile.

Control Panel \ Advanced tab \ Performance - Settings \ Advanced tab \ Virtual Memory settings \ Select the No Paging File option \ Set \ Restart

This will disable paging entirely and should also remove the pagefile (pagefile.sys) from your hard drive the next time you reboot the system.

If it does not do this, you can delete the file manually after rebooting. It is normally found in C:\ ... To see it:

Tools \ Folder Options \ View \ [dot] Show hidden files and folders, [un-check] Hide protected operating system files

Next, defragment the volume where your pagefile was previously.

Once your system is defragmented, open the Virtual Memory box again, change the pagefile back to System Managed Size, then, reboot your machine again.

This time, when you run the Disk Defragmenter, it should say your pagefile has only one fragment.

*****************************************************************

What DOS command can be used to temporarily disable Services that might be preventing successful Check Disk and Defrag?  How can I temporarily disable my DSL connection, since my anti-virus would be disabled?

First, let us see what non-MS Services show up in msconfig:

msconfig \ Services tab \ [check] Hide All Microsoft Services \

I see the following 9 non-MS Services on my machine, listed below.

When you double click on them in Services (Accessories \ Administrative Tools \ Services), you can get more information.

The following is listed in this format:

Display name - Startup type
Service name
Path to executable

If you type in:
sc query type= service state= all > allserviceslist.txt
(described below - this puts the text file on C:)
you get the additional info seen here

-----------------------------------------------------------------

These first 3 are on Automatic.  AVG is probably causing the problem, but I might as well disable the other 2 also (What service is my DSL connection?  Wonder why that does not show up.)

AVG Free WatchDog - Automatic, Started
avg9wd
"C:\Program Files\AVG\AVG9\avgwdsvc.exe"
SERVICE_NAME: avg9wd
DISPLAY_NAME: AVG Free WatchDog
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (NOT_STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Creative Audio Service - Automatic, Started
CTAudSvcService
C:\Program Files\Creative\Shared Files\CTAudSvc.exe
SERVICE_NAME: CTAudSvcService
DISPLAY_NAME: Creative Audio Service
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

NVIDIA Display Driver Service - Automatic, Started
nvsvc
C:\WINDOWS\system32\nvsvc32.exe
SERVICE_NAME: nvsvc
DISPLAY_NAME: NVIDIA Display Driver Service
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

-----------------------------------------------------------------

These 6 are on Manual.  If they were running, could they cause the issue?  I do not know.  Just try disabling the ones on Automatic for now.

AVG Security Toolbar Service - Manual
AVG Security Toolbar Service
C:\Program Files\AVG\AVG9\Toolbar\ToolbarBroker.exe
SERVICE_NAME: AVG Security Toolbar Service
DISPLAY_NAME: AVG Security Toolbar Service
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 1077   (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Creative Audio Engine Licensing Service - Manual
Creative Audio Engine Licensing Service
"C:\Program Files\Common Files\Creative Labs Shared\Service\CTAELicensing.exe"
SERVICE_NAME: Creative Audio Engine Licensing Service
DISPLAY_NAME: Creative Audio Engine Licensing Service
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 1077   (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

InstallDriver Table Manager - Manual
IDriverT
"C:\Program Files\Common Files\InstallShield\Driver\11\Intel 32\IDriverT.exe"
SERVICE_NAME: IDriverT
DISPLAY_NAME: InstallDriver Table Manager
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 1077   (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Windows CardSpace - Manual
idsvc
"C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\infocard.exe"
SERVICE_NAME: idsvc
DISPLAY_NAME: Windows CardSpace
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 1077   (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Microsoft Automated Troubleshooting Service - Manual
MatSvc
"C:\Program Files\Microsoft Fix it Center\Matsvc.exe"
SERVICE_NAME: MatSvc
DISPLAY_NAME: Microsoft Automated Troubleshooting Service
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 1077   (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Windows Media Player Networking Service - Manual
Windows Media Player Network Sharing Service (Dsplay name in Services)
WMPNetworkSvc
"C:\Program Files\Windows Media Player\WMPNetwk.exe"
SERVICE_NAME: WMPNetworkSvc
DISPLAY_NAME: Windows Media Player Network Sharing Service
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 1077   (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

*****************************************************************

Disable Services at Command Line
http://techrepublic.com.com/5208-11184-0.html?forumID=47&threadID=171983&messageID=1750216&tag=content;leftCol

Managing Windows XP Services with the Service Controller Command SC
http://commandwindows.com/sc.htm

-----------------------------------------------------------------

Using the SC command

Make sure you use the Service Name, as seen from when you click on it in Services, and not the display name. If you use the display name it will not work.

A service can be set to run automatically, manually, or not at all: Auto, Manual, Disabled ... The syntax is as follows:

sc config [ServiceName] start= flag

Note that there must be a space after the equals sign.

sc config [ServiceName] start= {boot|system|auto|demand|disabled}] [error= {normal|severe|critical|ignore}] [binpath= BinaryPathName] [group= LoadOrderGroup] [tag= {yes|no}] [depend= dependencies] [obj= {AccountName|ObjectName}] [displayname= DisplayName] [password= Password]

. . .

[start= {boot|system|auto|demand|disabled}]

. . . Translates into:

Automatic = auto
Manual = demand
Disabled = disabled

sc config [ServiceName] start= auto
sc config [ServiceName] start= demand
sc config [ServiceName] start= disabled

-----------------------------------------------------------------

The correct value for the parameter ServiceName may not always be obvious, and the next command can be used to find it for all services.

sc query

Information about services and drivers can be obtained with this command. Used alone it returns a list of running services with various information about the service.

To create a list of active drivers:
sc query type= driver

For a list of everything:
sc query state= all

Lists can be inconvenient to read on a screen, and can be redirected to a text file:

To create a text list of running services, use the command (this puts the text file on C:):
sc query > serviceslist.txt

sc query type= service state= all > allserviceslist.txt

-----------------------------------------------------------------

So, these are the 3 to be temporarily disabled, and then put back on auto:

AVG Free WatchDog
Creative Audio Service
NVIDIA Display Driver Service

sc config avg9wd start= disabled
sc config CTAudSvcService start= disabled
sc config nvsvc start= disabled

sc config avg9wd start= auto
sc config CTAudSvcService start= auto
sc config nvsvc start= auto

*****************************************************************

Do I need to un-check my seven Startups?  Use CCleaner \ Tools \ Startup .. to get a text output of them

msconfig \ Startup tab \ these are the only ones I have checked, 7 of them (after looking at all of them on sysinfo.org)

Yes HKLM:Run    nwiz            nwiz.exe /installquiet
Yes HKLM:Run    NvMediaCenter   RUNDLL32.EXE C:\WINDOWS\system32\NvMcTray.dll,NvTaskbarInit
Yes HKLM:Run    NvCplDaemon RUNDLL32.EXE C:\WINDOWS\system32\NvCpl.dll,NvStartup
Yes HKCU:Run    Replay AV   "C:\Program Files\ReplayAV 7.2\ReplayAV.exe" -quiet
Yes HKCU:Run    Calendarscope   "C:\Program Files\Calendarscope\cs.exe"
Yes HKLM:Run    kmw_run.exe kmw_run.exe
Yes HKLM:Run    AVG9_TRAY   C:\PROGRA~1\AVG\AVG9\avgtray.exe

Besides the fact that I do not know how to, I do not think I need to un-check anything here. The Services that I think are causing the problem have been disabled (I see that AVG cannot get updates), so that means they are not active.

*****************************************************************

Writing the BAT file - Remember to press enter after each command

-----------------------------------------------------------------

I have been running these two separately, with a little time in between, and have previously done the job:

ECHO y|CHKDSK D: /X/R
ECHO y|CHKDSK C: /R
SHUTDOWN -f -r -t 00

C:\WINDOWS\system32\defrag.exe d: -v>"c:\Documents and Settings\Administrator\Desktop\defrag d.txt"
C:\WINDOWS\system32\defrag.exe c: -v>"c:\Documents and Settings\Administrator\Desktop\defrag c.txt"

-----------------------------------------------------------------

10/14/10 If I combine them like this:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

C:\WINDOWS\system32\defrag.exe d: -v>"c:\Documents and Settings\Administrator\Desktop\defrag d.txt"
C:\WINDOWS\system32\defrag.exe c: -v>"c:\Documents and Settings\Administrator\Desktop\defrag c.txt"
sc config avg9wd start= disabled
sc config CTAudSvcService start= disabled
sc config nvsvc start= disabled
ECHO y|CHKDSK D: /X/R
ECHO y|CHKDSK C: /R
sc config avg9wd start= auto
sc config CTAudSvcService start= auto
sc config nvsvc start= auto
SHUTDOWN -f -r -t 00

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The results are ...

8:49 am - 9:07, 17 minutes, it defragged D:, it showed the page file as one fragment, but the report was incomplete, compared to what I have seen before, when I run the defrag bat alone

9:07 am - 9:58, 51 minutes, it defragged C:, then failed, it started flashing the code in the DOS window - the output file for C: had no info on it, I do not think it should have taken this long

Defrag incomplete, Check Disk did not even run

I do not think I need to force the Shutdown now, since I am disabling Services that I think are causing the problem.

*****************************************************************

10/15/10 Is this how to think of it, how to read the batch file . . . I think I can leave a blank line in between to see the the components easier. . . . What if I do the disables first, tell it I want to do a Check Disk of D: and C: at the next Restart, Defrag C: and D: (should work, now that 3 Services are Disabled), and then . . . where do I put in the code to auto re-enable?

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

sc config avg9wd start= disabled
sc config CTAudSvcService start= disabled
sc config nvsvc start= disabled

ECHO y|CHKDSK D: /X/R
ECHO y|CHKDSK C: /R

C:\WINDOWS\system32\defrag.exe d: -v>"c:\Documents and Settings\Administrator\Desktop\defrag d.txt"
C:\WINDOWS\system32\defrag.exe c: -v>"c:\Documents and Settings\Administrator\Desktop\defrag c.txt"

sc config avg9wd start= auto
sc config CTAudSvcService start= auto
sc config nvsvc start= auto

SHUTDOWN -r

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Results ...

It does the 3 Disables fine, but cannot get past ECHO y|CHKDSK D: /X/R, it flashes this code on the screen (see screenshot).  Control S pauses it, Control C gets the prompt to end task. It has worked before, now I do not know what is going on.  Discouraged :( need help

*****************************************************************
 
Share this answer
 
THE WAY TO GET IT TO WORK is at the bottom

These are the tests I did, necessary for me to come to the conclusion

--------------------------------------------------------

I think I only need to disable AVG Free WatchDog

Experiments, changing two things at a time, bad

Test 1
I do not need /X on D: ?
Yes, or it asks two more times, and it does not Check Disk D:
Defrag C: first, then D:, or I do not get the Defrag D: output

Test 2
What if I put /X on C:, and Defrag D: first, then C:?
The questions are more similar
It Defrags D: but not C:
It Check Disks both though

Test 3
If I Check Disk C: first, then D: and
if I Defrag C: first, then D:
it does not Defrag D:
it Check Disks D: first, then C:

Test 4
Check Disk can be in either order
Defrag D: can be first? No, then it does not Defrag C:

Test 5
If I Check Disk C: first, then D: and
If I Defrag C: first, then D:
It Check Disks them in the reverse order
and I get Defrag C: output, but no Defrag D: output

Test 6
If I Check Disk D: first, then C: and
If I Defrag C: first, then D:
It Check Disks them in the reverse order
and I get Defrag C: output, but no Defrag D: output
Must be the addition of /X to C:

Test 7
If I Check Disk C: first with no /X, then D: and
If I Defrag C: first, then D:
It Check Disks them in the reverse order
and I get Defrag C: output, but no Defrag D: output
The order in which I Check Disk makes a difference?

Test 8
If I Check Disk D: first, then C: and
If I Defrag C: first, then D:
It Check Disks them in the reverse order
and I get Defrag C: output, but no Defrag D: output
must be the /X on D:? I will remove it

Test 9
If I Check Disk C: first, then D: and
If I Defrag C: first, then D:
It Check Disks them in the reverse order . . . but it does not Check Disk D:
and I get Defrag C: output, but no Defrag D: output
I need the /X on D:, try running Defrag first

Test 10
If I Defrag C: first, then D:
If I Check Disk C: first, then D: and
It Check Disks them in the reverse order
and I get Defrag C: output, but no Defrag D: output
The order in which I Defrag makes a difference? Do D: first

Test 11
If I Defrag D: first, then C: and
If I Check Disk C: first, then D:
It Check Disks them in the reverse order
I get both Defrag C: and D: output!
Maybe I do not need to disable AVG, try that

Test 12
If I Defrag D: first, then C: and
If I Check Disk C: first, then D:
It Check Disks them in the reverse order
I get Defrag D: output, but no Defrag C: output
Works again if I disable AVG?

Test 13
AVG disabled
If I Defrag D: first, then C: and
If I Check Disk C: first, then D:
It Check Disks them in the reverse order
I got both outputs
Saw some message about unable to synchronize?
Put a pause command just before goin th Check Disk, so I do not have to run through that, it is working

Test 14
AVG not disabled
If I Defrag D: first, then C: and
If I Check Disk C: first, then D:
If I do not disable AVG, I get this message: Windows cannot initialize a synchronization event.

Test 15
AVG is disabled
If I Defrag D: first, then C: and
If I Check Disk C: first, then D:
With AVG disabled, I get this message: Windows cannot initialize a synchronization event.
Maybe I have to do a restart

Test 16
AVG is not disabled
If I Defrag D: first, then C: and
If I Check Disk C: first, then D:
Restart \ Windows cannot initialize a synchronization event.

Test 17
AVG is disabled
If I Defrag D: first, then C: and
If I Check Disk C: first, then D:
Windows cannot initialize a synchronization event.

***************************************************************

http://superuser.com/questions/160926/windows-cannot-initialize-a-synchronization-event

[1] Try defragging drive C last.

[2] Check to see if you have Offline Files enabled. In the Windows Explorer menu, choose Tools, Folder Options. On the Offline Files tab, if they are enabled, try disabling them. If you need offline files, I guess this is not really a solution, but frankly the Windows Offline Files feature is a disaster anyway and I would not trust it with a readme file.

Tools \ Folder Options \ Offline Files ... what I had:
[check] Enable Offline Files
Synchronize all offline files when logging on
[check] Synchronize all offline files before logging off
[check] Display a reminder every: 60 mins
Create an Offline Files shortcut on the desktop
Encrypt offline files to secure data

I have un-checked these:
[check] Enable Offline Files
[check] Synchronize all offline files before logging off
[check] Display a reminder every: 60 mins

I tried both of these at the same time and now it works. Thanks for the suggestions.

You are welcome. Now I am wondering which one fixed the problem.

... this did not work for me

***************************************************************

Test 17
AVG is is not disabled
I was doing Defrag C: last . . . I still get error message either way
Windows cannot initialize a synchronization event.

Test 18
AVG is is not disabled
If I Defrag D: first, then C: and

http://community.spiceworks.com/topic/111584
defrag.exe returns the error. But dfrg.msc is able to analyze and defrag successfully.

Test 19
What if I just disable all non-MS Services?
Two do not say SUCCESS
AVG Security Toolbar Service
Creative Audio Engine Licensing Service
says
Modifies a service entry in the registry and Service Database.

***************************************************************

Fed up

The way I got this to work before was to un-check all the non-MS Sevices, all Startups, and to disable the DSL connection, and then let the separate bat files run. Maybe doing a Restart takes something out of memory. I will put a Restart in the bat file, after Disabling the Services, and before doing the Defrag . . . I see that it does the Disables, starts to give a 30 second countdown, and starts doing the first of the Defrags, when it comes back to the main screen, it does not do the Defrags.

In msconfig, I see that there are no non-MS Services.
What if I do not Disable the two that say
Modifies a service entry in the registry and Service Database ...
AVG Security Toolbar Service
Creative Audio Engine Licensing Service ...
after a Restart, do they show up in msconfig?

***************************************************************

Better approach - I got this to work before - I recalled this info:

AVG Free WatchDog - Automatic, Started
avg9wd
C:\Program Files\AVG\AVG9\avgwdsvc.exe
SERVICE_NAME: avg9wd
DISPLAY_NAME: AVG Free WatchDog
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(NOT_STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

. . . (NOT_STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)

So AVG can only be Disabled through a Shutdown?

Before, with all non-MS Services and Startups unchecked, defrag of both C: and D: works
Which Service or Statup could it be? I have 9 non-MS Services and 7 Startups:

--------------------------------------------------------

9 NON-MS SERVICES

AVG Free WatchDog
AVG Security Toolbar Service
NVIDIA Display Driver Service
Creative Audio Engine Licensing Service
Creative Audio Service
InstallDriver Table Manager
Microsoft Automated Troubleshooting Service
Windows CardSpace
Windows Media Player Networking Service

7 STARTUPS

AVG9_TRAY, C:\PROGRA~1\AVG\AVG9\avgtray.exe
nwiz, nwiz.exe /installquiet
NvMediaCenter, RUNDLL32.EXE C:\WINDOWS\system32\NvMcTray.dll,NvTaskbarInit
NvCplDaemon, RUNDLL32.EXE C:\WINDOWS\system32\NvCpl.dll,NvStartup
Replay AV, C:\Program Files\ReplayAV 7.2\ReplayAV.exe -quiet
Calendarscope, C:\Program Files\Calendarscope\cs.exe
kmw_run.exe, kmw_run.exe

--------------------------------------------------------

I will have to Restart my computer 16 times, and try to Defrag 16 times to figure out by the process of elimination?
Or, I will try un-checking in groups? AVG, Nvidia, Windows, then the balance

--------------------------------------------------------

I suspect that the one preventing it is AVG, and, this is discussed on their web page, AVG says to run defrag in Safe Mode
http://forums.avg.com/us-en/avg-free-forum?sec=thread&act=show&id=40883

--------------------------------------------------------

Also discussion here:

http://forums.avg.com/us-en/avg-free-forum?sec=thread&act=show&id=62297#post_62297

I found the solution to this problem on the Piriform Forum: http://forum.piriform.com/index.php?showtopic=22921

I have tried this out on my own computer (Windows XP SP3 Home) and it works!

I had never before experienced this problem with AVG 9. It only started after I began using CCleaner. It is quite possible that other third party software with likewise activity may cause the same problem.

What seems to be the matter is that AVG apparently locks the log files out of self-protection against manipulation by malicious software. When running third party disk cleanup software - such as CCleaner - before defragmenting, AVG may interpret such activity as potentially malicious. So it may lock the log files to make them inaccessible. As a result the subsequent defragmentation of the log files becomes impossible. The solution is to run CCleaner after defragmenting the drive. Proceeding in that way, the AVG log files will be perfectly defragmented.

Mnd1997 pointed out on the Piriform Forum that a fresh reboot will release the locks on the log files. So defragmenting after rebooting and before running software like CCleaner will include the AVG log files.

As indicated by Andavari in the same Piriform Forum thread, AVG is not unique in such self-protective behavior. I think, however, that it would help if AVG was a bit more clever in making a distinction between malicious and non-malicious processes. If it would recognize CCleaner as a non-malicious program, it would not have to decide to lock these files against its activity.

This solution is only a workaround method, but we will probably have to do with it until AVG comes up with a more discriminate method for securing its logfiles against malicious attacks.

--------------------------------------------------------

I un-checked all three \ Restart \ and Defrag worked

SERVICES
AVG Free WatchDog
AVG Security Toolbar Service

STARTUP
AVG9_TRAY C:\PROGRA~1\AVG\AVG9\avgtray.exe

I thought, what if I leave the Toolbar checked \ Restart \ and Defrag worked
I thought, what if I leave the Free WatchDog checked \ Restart \ and Defrag worked

The only one I have to un-check, and do a Restart with, is AVG9_TRAY

--------------------------------------------------------

If I left AVG9_TRAY checked, though, then I got the error
Windows cannot initialize a synchronization event.

So I just un-checked avgtray.exe, and Defrag worked

I tried it again later, and it did not work!

So, something is going on that does not make sense to me - and it is not really important to figure out

*****************************************************************
*****************************************************************

THE WAY TO GET IT TO WORK

The simplest way to do this is to disable all Services and Startups - and your DSL connection, since your anti-virus will be off.

I used www.sysinfo.org to see which Startups I can leave un-checked, this saves on memory.

AVG says to run defrag in Safe Mode.

I had all Services disabled, but not the Startups, and got the error:
Windows cannot initialize a synchronization event.
so I know that Startups could be the cause.

Side Note: I read somewhere that 126 MB minimum is needed on C: for a debugging information file, so I currently put 2900 on D: and 170 on C: . . . Total of 3070

--------------------------------------------------------

Control Panel \ Network Connections \ [right-click] Local Area Connection 5 \ Disable

Start \ Run \ msconfig \
Services tab \ [check] Hide All Microsoft Services \ Disable All \ Apply
Startup tab \ Disable All \ Apply
Close \ Restart

Then let Scheduled Tasks run the following bat file at 1:00 AM, on the third Tuesday of every month, view the results in the AM.

--------------------------------------------------------

C:\WINDOWS\system32\defrag.exe c: -v>"c:\Documents and Settings\Administrator\Desktop\defrag c.txt"
C:\WINDOWS\system32\defrag.exe d: -v>"c:\Documents and Settings\Administrator\Desktop\defrag d.txt"

ECHO y|CHKDSK C: /R
ECHO y|CHKDSK D: /X/R

SHUTDOWN -r
 
Share this answer
 
You seem to be confused between QA and article. Did you mean to submit an article?
 
Share this answer
 
Hi! Sorry, it's kind of an article question I guess. Maybe I'm just looking for comments as to if there's a better way.
 
Share this answer
 
Comments
LloydA111 17-Oct-10 15:52pm    
Perhaps one of the CP "technical blogs"? I'm sure something like this would make a good one :)
LloydA111 17-Oct-10 15:53pm    
*Perhaps you should make one of the CP "technical blogs" about this.
Here is the question ... is there any command other than SC that could be used to stop this service, the AVG Free WatchDog?

I think it can only be stopped by doing a Restart, after un-checking all AVG in Services and Startups.

(please see below)

*************************************

In my Services, AVG Free WatchDog is currently: Automatic, Started

-------------------------------------

If I run this bat file:

sc config avg9wd start= disabled
PAUSE

It says:
[SC] ChangeServiceConfig SUCCESS

I then go to Services, click on Refresh, and see that AVG WatchDog changes to: Disabled, Started

... so the next time I do a Restart, it would be Disabled

-------------------------------------

If I add the stop command and run this bat file:

sc config avg9wd start= disabled
sc stop avg9wd
PAUSE

It says:
[SC] ChangeServiceConfig SUCCESS
[SC] ControlService FAILED 1052: The requested control is not valid for this service

I then go back to Services, click on Refresh, and see that AVG WatchDog is still: Disabled, Started

-------------------------------------

- - - - - Is there any other command that could be used to stop this service?

*************************************

I would think I can run this bat file to get it back to Automatic, Started

sc config avg9wd start= auto
sc start avg9wd

The first command works:
[SC] ChangeServiceConfig SUCCESS
[SC] StartService FAILED 1056: An instance of the service is already running.

I then go back to Services, click on Refresh, and see that AVG WatchDog is back to: Automatic, Started

So I did not need to Start it

*************************************

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx?mfr=true
 
Share this answer
 
SUMMARY AND [my] CONCLUSION

I want Scheduled Tasks to wake up the computer out of Standby at 1 am, and run this code in a bat file, to Defrag and Check Disk:

--------------------------------------------------------

C:\WINDOWS\system32\defrag.exe c: -v>"c:\Documents and Settings\Administrator\Desktop\defrag c.txt"
C:\WINDOWS\system32\defrag.exe d: -v>"c:\Documents and Settings\Administrator\Desktop\defrag d.txt"

ECHO y|CHKDSK C: /R
ECHO y|CHKDSK D: /X/R

SHUTDOWN -r

--------------------------------------------------------

AVG says to do this in Safe Mode. If you go to:

msconfig \ BOOT.INI \ with /SAFEBOOT MINIMAL, DSL is automatically disabled

I have found that Standby is not available in Safe Mode though, so Scheduled Tasks cannot wake up the computer at 1 am to run the bat file.

--------------------------------------------------------

Disabling these the night before seems to be the only way:

Control Panel \ Network Connections \ [right-click] Local Area Connection 5 \ Disable

Start \ Run \ msconfig \
Services tab \ [check] Hide All Microsoft Services \ Disable All \ Apply
Startup tab \ Disable All \ Apply
Close \ Restart

--------------------------------------------------------

I find that it is frozen in the AM when I bring it out of Standby (everything ran though).

If I use the Task Manager to put it back into Standby, and bring it back out, it is still frozen.

This has worked in the past when I was having this problem for some other reason, unsigned drivers I think.

So I then do a Restart. Next, I can re-enable my non-MS Services and Startups, and do another Restart.

I am still wondering if there is a DOS command to Disable non-MS Services - and how would I disable Startups?

I recall from:

SC QUERY avg9wd . . . that it says:
STATE: 4 RUNNING
(NOT_STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)

Maybe I could put Defrag and Check Disk on the Exclude list in AVG, but then there is the message about handles on the hard drive being locked.

So it seems like doing a Restart with these items un-checked is the only way, and probably the simplest.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900