Is it possible to edit StateRepository-Machine files in newer Win10?

Discussion in 'Windows 10' started by DirtyAngelicaSecured, Nov 23, 2021.

  1. DirtyAngelicaSecured

    Mar 30, 2020
    101
    17
    10
    To get rid of traces of UWP ("Inbox") Apps, I used to be able to open and edit "C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" file with a SQL database editor. Later builds of Windows 10 (19041+) began preventing saving changes to that file, even when opened with NSudo and/or some other TrustedInstaller privilege methods.

    Is now not possible to make changes to that file?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,693
    60
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. #3 Deleted member 1385001, Nov 24, 2021
    Last edited by a moderator: Nov 24, 2021
    Code:
    echo --- Remove SystemApps
    cd /d %~dp0
    SetACL -ot "reg" -on "HKLM\SYSTEM\CurrentControlSet\Services\StateRepository" -actn setowner -ownr "n:Administrators"
    SetACL -ot "reg" -on "HKLM\SYSTEM\CurrentControlSet\Services\StateRepository" -actn ace -ace "n:Administrators;p:full"
    Powershell -Command "Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\StateRepository' 'Start' 4 -Verbose"
    Powershell -Command "Stop-Service -Name StateRepository -Force -Verbose"
    Powershell -Command "Get-Service -Name StateRepository -Verbose"
    SetACL -ot "file" -on "%ProgramFiles%\WindowsApps" -actn setowner -ownr "n:Administrators"
    SetACL -ot "file" -on "%ProgramFiles%\WindowsApps" -actn ace -ace "n:Administrators;p:full"
    SetACL -ot "file" -on "%ProgramData%\Microsoft\Windows\AppRepository" -actn setowner -ownr "n:Administrators"
    SetACL -ot "file" -on "%ProgramData%\Microsoft\Windows\AppRepository" -actn ace -ace "n:Administrators;p:full"
    SetACL -ot "file" -on "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" -actn setowner -ownr "n:Administrators"
    SetACL -ot "file" -on "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" -actn ace -ace "n:Administrators;p:full"
    IF EXIST "%ProgramData%\Microsoft\Windows\AppRepository\PackageRepository.edb" del /f /s /q /a "%ProgramData%\Microsoft\Windows\AppRepository\PackageRepository.edb"
    Powershell -Command "Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\StateRepository' 'Start' 2 -Verbose"
    Powershell -Command "Start-Service -Name StateRepository -Verbose"
    Powershell -Command "Get-Service -Name StateRepository -Verbose"
    TASKLIST /svc /fi "services eq StateRepository"
    TASKKILL /F /FI "services eq StateRepository" /T
    SQLite3 "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" "DROP TRIGGER IF EXISTS TRG_AFTER_UPDATE_Package_SRJournal;"
    SQLite3 "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" "DROP TRIGGER IF EXISTS TRG_AFTERUPDATE_Package_SRJournal;"
    SQLite3 "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" "UPDATE Package SET IsInBox=0 WHERE IsInBox=1;"
    Powershell -Command "Get-AppxPackage -AllUsers | Out-GridView -PassThru -Title 'Remove System Apps' | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue -Verbose"
    echo ======================================================
    echo --- Recheck SystemApps Removal [IF Some Apps Are Left Before This Time They Will be Removed]
    SetACL -ot "reg" -on "HKLM\SYSTEM\CurrentControlSet\Services\StateRepository" -actn setowner -ownr "n:Administrators"
    SetACL -ot "reg" -on "HKLM\SYSTEM\CurrentControlSet\Services\StateRepository" -actn ace -ace "n:Administrators;p:full"
    Powershell -Command "Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\StateRepository' 'Start' 4 -Verbose"
    Powershell -Command "Stop-Service -Name StateRepository -Force -Verbose"
    Powershell -Command "Get-Service -Name StateRepository -Verbose"
    SetACL -ot "file" -on "%ProgramFiles%\WindowsApps" -actn setowner -ownr "n:Administrators"
    SetACL -ot "file" -on "%ProgramFiles%\WindowsApps" -actn ace -ace "n:Administrators;p:full"
    SetACL -ot "file" -on "%ProgramData%\Microsoft\Windows\AppRepository" -actn setowner -ownr "n:Administrators"
    SetACL -ot "file" -on "%ProgramData%\Microsoft\Windows\AppRepository" -actn ace -ace "n:Administrators;p:full"
    SetACL -ot "file" -on "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" -actn setowner -ownr "n:Administrators"
    SetACL -ot "file" -on "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" -actn ace -ace "n:Administrators;p:full"
    IF EXIST "%ProgramData%\Microsoft\Windows\AppRepository\PackageRepository.edb" del /f /s /q /a "%ProgramData%\Microsoft\Windows\AppRepository\PackageRepository.edb"
    Powershell -Command "Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\StateRepository' 'Start' 2 -Verbose"
    Powershell -Command "Start-Service -Name StateRepository -Verbose"
    Powershell -Command "Get-Service -Name StateRepository -Verbose"
    TASKLIST /svc /fi "services eq StateRepository"
    TASKKILL /F /FI "services eq StateRepository" /T
    SQLite3 "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" "DROP TRIGGER IF EXISTS TRG_AFTER_UPDATE_Package_SRJournal;"
    SQLite3 "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" "DROP TRIGGER IF EXISTS TRG_AFTERUPDATE_Package_SRJournal;"
    SQLite3 "%ProgramData%\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" "UPDATE Package SET IsInBox=0 WHERE IsInBox=1;"
    Powershell -Command "Get-AppxPackage -AllUsers | Out-GridView -PassThru -Title 'Remove System Apps' | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue -Verbose"
    
    Note : Sqlite3 & setacl are needed next to script.
    After i get a single comment or view from anybody on MDL forums on this comment of mine it will be removed on the go.