c++点滴

做生活的有心人
posts - 10, comments - 0, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

2014年7月7日

Consider this scenario:

You re-install or upgrade Vista / Windows 2008 / Windows 7 in a system. That may result the creation of "Windows.old" folder. You may try to delete that folder and its contents ; that may not work as expected - you may get multiple access denials and the folder "Windows.old" cannot be removed. This issue may be seen even if you have administrator privileges to the box.

For such a scenario, you may create a batch file based on the code below and run that batch file to delete the "Windows.old" folder:

REM JK-Windows.Old Deleter Version 1.0.181109 by jkadeesh

@echo off

setlocal

Title Windows.Old Deleter

set BAT_HOME=%~dp0
set BAT_NAME=%~s0
set BATFILE=%~nx0
set DRVLET=%~d0


if "%1"=="" goto interactive

REM Flash related lines are meant for deleting Flash specific .OCX files which cannot be easily deleted

if exist %1\Windows\System32\Macromed\Flash CD /D %1\Windows\System32\Macromed\Flash && cacls *.* /P Everyone:F

cd /d %DRVLET%

takeown /f %1 /R /d y
icacls %1 /grant administrators:F /t
rd /s /q %1

goto end


:interactive

cls

cd /d %DRVLET%\

IF EXIST %DRVLET%\Windows.old ECHO. && ECHO Found %DRVLET%\Windows.old && GOTO Auto

IF NOT EXIST %DRVLET%\Windows.old ECHO. && ECHO NOT FOUND %DRVLET%\Windows.old && ECHO.


echo Enter folder name [with complete path] which needs to be deleted:
echo.
echo To exit type "x" and press Enter key

echo.
echo.

set /p user=Folder Name[with path]:

if "%user%"=="x" goto end


if exist %user%\Windows\System32\Macromed\Flash CD /D %user%\Windows\System32\Macromed\Flash && cacls *.* /P Everyone:F

cd /d %DRVLET%\

takeown /f %user% /R /d y
icacls %user% /grant administrators:F /t
rd /s /q %user%


if not "%user%"=="x" goto interactive

goto end


:Auto
cls
ECHO.

cd /d %DRVLET%\

set user=Windows.old

if exist %DRVLET%\%user%\Windows\System32\Macromed\Flash CD /D %DRVLET%\%user%\Windows\System32\Macromed\Flash && cacls *.* /P Everyone:F

cd /d %DRVLET%\

takeown /f %user% /R /d y
icacls %user% /grant administrators:F /t
rd /s /q %user%


goto end

:end
ECHO.
ECHO Exiting...
ECHO.
pause

How to use the above code?

0. Disable User Access control [temporarily] - Once this task of deleting files / folders is completed, you may want to re-enable User Access Control. To disable UAC, go to Control Panel > User Accounts > Turn User Account Control on or off ; then uncheck the option "Use User Account Control (UAC) to help protect your computer" and click OK. Then restart the computer.

1. Copy/paste the code to Notepad

2. Save the file with the file name as: DeleteFiles.bat to C:\ drive [any location is ok - you need to go to the relevant location using the command line in step: 4]

Note that the 'Save as type' should be selected as "All Files (*.*)" before you click the Save button.

3. Go to Command prompt

4. Type CD \  to go to C:\

5. Type DeleteFiles foldername and then press Enter key

By default, the folder name is C:\Windows.old.

If the Windows.old folder resides in D:\ [or a different drive], then enter the drive letter accordingly along with the folder name.

6. Then you will notice a lot of operation in the command window and the script will end with "Exiting..." . Press any key to exit the script.

Then you will find Windows.old folder is completely removed - Note that with this method the contents of Windows.old folder will not won't be sent to the Recycle bin.

DeleteFiles.bat can be run without supplying the folder name also - in that scenario, it will consider Windows.old folder present in the current drive from which you run the batch file.

This posting is provided "AS IS" with no warranties. Use of included tools and reports are subject to the terms specified at 
http://www.microsoft.com/info/cpyright.htm

posted @ 2014-07-07 17:46 huoxudong125 阅读(230) | 评论 (0)编辑 收藏

2014年7月4日

c++ native code 中的正则表达式和manage code中正则表达式的区别

posted @ 2014-07-04 17:21 huoxudong125 阅读(171) | 评论 (0)编辑 收藏

四种转换类型解释。

posted @ 2014-07-04 17:13 huoxudong125 阅读(100) | 评论 (0)编辑 收藏

C++ 程序启用OPM

posted @ 2014-07-04 17:11 huoxudong125 阅读(272) | 评论 (0)编辑 收藏

c++ 编译警告

posted @ 2014-07-04 17:05 huoxudong125 阅读(173) | 评论 (0)编辑 收藏

c++ 函数如何返回一个对象(class 或者struct)

posted @ 2014-07-04 17:04 huoxudong125 阅读(336) | 评论 (0)编辑 收藏

c++ FileMemoryMaping的技术介绍和实例讲解

posted @ 2014-07-04 16:58 huoxudong125 阅读(159) | 评论 (0)编辑 收藏

C++ 中CHAR,WCHAR,TCHAR的区别与联系,同时涉及到string,wstring所牵涉到的函数问题。

posted @ 2014-07-04 16:57 huoxudong125 阅读(134) | 评论 (0)编辑 收藏

介绍C++生成DLL如何导出,供C#导入使用通过[DLLIMPORTAttribute]。以及其注意事项。

posted @ 2014-07-04 16:55 huoxudong125 阅读(141) | 评论 (0)编辑 收藏

讲解std:string->System::String

posted @ 2014-07-04 16:53 huoxudong125 阅读(219) | 评论 (0)编辑 收藏