How To Delete Files From Old System Disk?


  1. Posts : 524
    win10
       #1

    How To Delete Files From Old System Disk?


    I want to delete the old Windows folder and a Windows.old folder from a system disk that had a totally corrupt system on and which I've just replaced with a new disk, new system.

    I'm copying all my data files off it and then I'll wipe it clean.

    That will delete the windows and windows.old, I know, but I want to know how to do it with permissions and whatever.

    I'd like to know what's going on. I've never gotten on top of Windows permissions, they've always had me foxed.

    These folder now - last one I looked at was a simple 'found.006' thing - tell me I need admin permission to delete them. Well I am logged in as admin.

    And I blunder around trying to improve things and this admin - me - clearly seems to have full permissions to do anything he likes...

    Is there any simple help I could understand will get me going on this thorny thing... ?
      My Computer


  2. Posts : 5,330
    Windows 11 Pro 64-bit
       #2

    This script will add take ownership context menu.

    Code:
    @Echo Off
    
    
    REM  --> Check for permissions
    Reg query "HKU\S-1-5-19\Environment" 
    REM --> If error flag set, we do not have admin.
    if %errorlevel% NEQ 0 (
    ECHO                 **************************************
    ECHO                  Running Admin shell... Please wait...
    ECHO                 **************************************
    
        goto UACPrompt
    ) else ( goto gotAdmin )
    
    :UACPrompt
        echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
        set params = "%*:"=""
        echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
    
        "%temp%\getadmin.vbs"
        del "%temp%\getadmin.vbs"
        exit /B
    
    
    :gotAdmin
    
    Cls & Mode CON  LINES=11 COLS=104 & Color 0E & Title Created By FreeBooter
    Echo.
    Echo.
    Echo.
    Echo.       
    Echo         Do You Want To Add Take Ownership to the Right-Click Menu in Windows Explorer (Y/N)?    
    Echo.       
    Echo.
    Echo.
    
    
    Set /p input= RESPONSE: 
    
    If /i  Not %input%==Y (Goto :_Ex) Else (Goto :_Start) 
    
    :_Ex
    If /i Not %input%==N  (Goto :EOF) Else (Goto :_RegRestore)
    
    
    
    :_Start
    
    Reg.exe add "HKCR\*\shell\runas" /ve /t REG_SZ /d "Take Ownership" /f > Nul
    Reg.exe add "HKCR\*\shell\runas" /v "NoWorkingDirectory" /t REG_SZ /d "" /f > Nul
    Reg.exe add "HKCR\*\shell\runas\command" /ve /t REG_SZ /d "cmd.exe /c takeown /f \"%%1\" && icacls \"%%1\" /grant administrators:F" /f > Nul
    Reg.exe add "HKCR\*\shell\runas\command" /v "IsolatedCommand" /t REG_SZ /d "cmd.exe /c takeown /f \"%%1\" && icacls \"%%1\" /grant administrators:F" /f > Nul
    Reg.exe add "HKCR\Directory\shell\runas" /ve /t REG_SZ /d "Take Ownership" /f > Nul
    Reg.exe add "HKCR\Directory\shell\runas" /v "NoWorkingDirectory" /t REG_SZ /d "" /f > Nul
    Reg.exe add "HKCR\Directory\shell\runas\command" /ve /t REG_SZ /d "cmd.exe /c takeown /f \"%%1\" /r /d y && icacls \"%%1\" /grant administrators:F /t" /f > Nul 
    Reg.exe add "HKCR\Directory\shell\runas\command" /v "IsolatedCommand" /t REG_SZ /d "cmd.exe /c takeown /f \"%%1\" /r /d y && icacls \"%%1\" /grant administrators:F /t" /f > Nul
    
    
    Cls & Mode CON  LINES=11 COLS=60 & Color 0E & Title Created By FreeBooter
    Echo.
    Echo.
    Echo.
    Echo.       
    Echo          Take Ownership Context Menu Enabled   
    Echo.       
    Echo.
    Echo. 
    
    Taskkill /im Explorer.exe /f >Nul
    
    Start Explorer.exe
    
    ping -n 6 localhost >Nul 
    Exit
    
    
    :_RegRestore
    
    
    Reg.exe delete "HKCR\*\shell\runas" /f > Nul
    Reg.exe delete "HKCR\Directory\shell\runas" /f > Nul
    
    
    Cls & Mode CON  LINES=11 COLS=60 & Color 0E & Title Created By FreeBooter
    Echo.
    Echo.
    Echo.
    Echo.       
    Echo         Take Ownership Context Menu Disabled    
    Echo.       
    Echo.
    Echo. 
    
    Taskkill /im Explorer.exe /f >Nul
    
    Start Explorer.exe
    
    ping -n 6 localhost >nul 
    Exit
      My Computer


  3. Posts : 4,201
    Windows 10 Pro x64 Latest RP
       #3

    Although you are logged in as an admin Windows now uses a Token system to control admin Access.

    This is done via the UAC "User Access Control" and this must be invoked to elevate your user to a full admin level.

    You should be able to open the security tab of the folders you cannot access to delete and add your actual user to the list of "full control" users, this is the traditional and safest way to work. There are shortcuts as provided above but the way I work for a quick delete is to Find Explorer.exe in the windows folder right click and select "run as administrator" you can then use this copy of File Explorer to modify almost all of the files and folders on the system.

    There are some folders that are for security reasons not even accessible to an Admin account, in these cases you will need to enable and use the hidden administrator to perform these tasks.

    I prefer to use the old method but I also use this method over the take ownership method due to being taught this way when training to be a system admin in industry both methods are acceptable
      My Computers


  4. Posts : 524
    win10
    Thread Starter
       #4

    That's beautiful. Works like a charm. Wonderful.<br><br>But surely that's not how win10 expects us to cope with this, is it? Not by design? So is this a glitch, a flaw, a problem with win10 or just my machine - that old disk that gave me so much trouble?<br><br>And still is really, isn't it?<br><br>For the script did a wonderful job on the found and the windows folder but windows.old has come up with a new hassle - now it keeps stopping on the delete claiming it can't find the file... the folder.... that it 'no longer exists in this location..'<br><br>Any clues on that ?<br><br>It's quite mysterious this windows thing isn't it?

    edit.

    Hmmm... sorry about that bad text. I lost the internet connection, don't know why, and things went loopy for a while...
      My Computer


  5. Posts : 5,330
    Windows 11 Pro 64-bit
       #5

    Have you used Disk Cleanup utility to delete Windows.old folder.
      My Computer


  6. Posts : 524
    win10
    Thread Starter
       #6

    Have you used Disk Cleanup utility to delete Windows.old folder.
    Nope. Where's that? Should I? I certainly should know about it. I'll look for it. :)


    add your actual user to the list of "full control" users,
    I thought that's what I'd been doing before I posted here.

    There's often a difference between what I think I'm doing and what I am doing though....

    edit: Phew... found disk cleanup... write in search field and there is a disk selection, click 'ok' and woaa.. off it goes looks like it's cleaning the disk without asking me what I want...

    things like that make me nervous, I abort them...

    I think good programming would alert you to what's coming....

    If I'd stayed with it I would have been able to choose files.... ?

    edit: aaah... I'm too nervous... yes, stay with it, it was only calculating something...

    thanks for the link to the page.. I just saw that second post.... :)
      My Computer


  7. Posts : 5,330
    Windows 11 Pro 64-bit
       #7
      My Computer


  8. Posts : 31,675
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #8

    If you want to leave nothing on the old drive, not even partitions, then the quickest way to get rid of everything is to use DISKPART's CLEAN command (for a forensic wipe there is a CLEAN ALL command, but that can take a long time).

    CLEAN will leave the whole drive unallocated, so you'll have deleted the recovery partition and other hidden system partitions too, leaving the whole disk available for reformatting.


    Erase Disk using Diskpart Clean Command in Windows 10
      My Computers


  9. Posts : 524
    win10
    Thread Starter
       #9

    I will use diskpart's clean. After I've got all my data off it. Thanks for the tip.

    That looks like amanita muscaria to me......

    :)
      My Computer


  10. Posts : 31,675
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #10

    abrogard said:
    I will use diskpart's clean. After I've got all my data off it. Thanks for the tip.

    That looks like amanita muscaria to me......

    :)

    Indeed it is - watch it for 33 seconds
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:07.
Find Us




Windows 10 Forums