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
    100
    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. BAU

    BAU MDL Expert

    Feb 10, 2009
    1,234
    3,290
    60
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. (\_/)^(\_/)

    (\_/)^(\_/) MDL Member

    May 31, 2020
    1,587
    1,333
    60
    #3 (\_/)^(\_/), Nov 24, 2021
    Last edited: 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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...