Remove ads from Windows 8 apps

Discussion in 'Windows 8' started by 1337chaos, Mar 10, 2013.

  1. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,466
    990
    60
    #81 Humphrey, Aug 11, 2013
    Last edited by a moderator: Apr 20, 2017
    In some configurations, this will happen. For example, if I am on a regular user account and run something as admin, it will try looking in the administrators profile area for the files. I have got around that problem by adding
    Code:
    %~DP0
    to the beguining of a batch file to get it to start running from inside the folder it was called from.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. 1337chaos

    1337chaos MDL Novice

    Mar 10, 2013
    40
    62
    0
    #82 1337chaos, Aug 12, 2013
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Also inform him that you only need to run the TakeControlOf.cmd as an administrator. The AdRemover.bat needs to be run normally, not as an administrator. I'll try to add something to the batch so that it doesn't matter if you run AdRemover as an admin or not. (thanks Humphrey if it works :biggrin:)

    Humphrey: Googled that command. Apparently it's %~dp0. I can't seem to get it to work on my batch though. According to most sources, I would put it in front of the file that I want to take from the current directory of the batch. For example:

    Code:
    do (copy Generic.xaml "%%a")
    Would become

    Code:
    do (copy %~dp0Generic.xaml "%%a")
    Yet it doesn't do anything but break the code. I'm unfamiliar with that command, so if you could shed some light on it or maybe give me an example, that would help. As for now, I'm simply cautioning people to NOT run the AdRemover.bat as an administrator.
     
  3. 1337chaos

    1337chaos MDL Novice

    Mar 10, 2013
    40
    62
    0
    I've updated the app to support ad removal in Sky News. Also, I didn't see any ads in gmail calendar or Accuweather after running the new v0.8 script. Try it out!
     
  4. Ron1958

    Ron1958 MDL Junior Member

    Feb 21, 2010
    55
    1
    0
    Can't get this to work anymore, even with the new 0.8 script.
    Yes I run the take control as admin, and the remove adds normal.

    Any thoughts on this?
     
  5. 1337chaos

    1337chaos MDL Novice

    Mar 10, 2013
    40
    62
    0
    What OS are you using? This doesn't work on 8.1, only 8.
     
  6. Ron1958

    Ron1958 MDL Junior Member

    Feb 21, 2010
    55
    1
    0
    Windows 8 Pro
    I have tried running it as admin, even went as far as opening an admin command prompt, add copying what was inside the takecontolof, and that didn't work either.
     
  7. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,466
    990
    60
    #87 Humphrey, Aug 18, 2013
    Last edited by a moderator: Apr 20, 2017
    Code:
    @echo off
    CD %~DP0
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "AdDuplex.Windows\Themes"') do (copy Generic.xaml "%%a")
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "Microsoft.Advertising.WinRT.UI\Themes"') do (copy Generic.xaml "%%a")
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "Microsoft.PlayerFramework.Advertising\Themes"') do (copy Generic.xaml "%%a")
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "Content\Ad\Images"') do (rmdir /s /q "%%a")
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "Images\Ad"') do (rmdir /s /q "%%a")
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "Common\AdsModule\View"') do (copy VideoRollAd.xaml "%%a")
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "Common\AdsModule\View"') do (copy MainPageAd.xaml "%%a")
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "Controls\Ad"') do (copy OasAdControl.xaml "%%a")
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "msacl.ui\Controls\Banners"') do (copy AdControl.xaml "%%a")
    for /f "delims=" %%a in ('dir "%programfiles%\WindowsApps" /ad /b /s ^| find /i "BritishSkyBroadcasting.SkyNews_2.0.0.0_neutral__0b9xnhb6xcwd0\Views"') do (copy GroupedItemsPage.xaml "%%a")
    setlocal
    set cwd=%CD%
    set p=MSAdvertisingJS\ads
    cd /d "%programfiles%\WindowsApps"
    for /d %%I in (*) do (
        if exist "%%I\%p%\" (
            pushd "%%I\%p%\"
            del /q bootstrap.html
            popd
        )
    )
    :: (change back to original directory)
    cd /d "%cwd%"
    
    This %~DP0 is put at the top of the file with CD so that the working directory the command prompt has is the directory it is being ran from. You can also put the in front of the the files you are working with but I have not done this.

    For those that want to restore the ownership information:
    Code:
    icacls "%programfiles%\WindowsApps" /setowner "NT Service\TrustedInstaller" /T /C
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. 1337chaos

    1337chaos MDL Novice

    Mar 10, 2013
    40
    62
    0
    #88 1337chaos, Aug 18, 2013
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Excellent! I'll wait to update the script until I add some more ad removals. I do appreciate it though.

    @Ron1958: What does it say when you try running it as an admin? Are you SURE you're not running 8.1? I know you replied earlier in the thread saying that it doesn't work on 8.1.
     
  9. Ron1958

    Ron1958 MDL Junior Member

    Feb 21, 2010
    55
    1
    0
    No I'm sure, I reformatted, and started over.

    Thank You for any help on this.
     
  10. 1337chaos

    1337chaos MDL Novice

    Mar 10, 2013
    40
    62
    0
    Can you open up an admin command prompt, drag and drop the TakeControlOf.cmd file into it and screenshot the output for me?
     
  11. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,466
    990
    60
    #91 Humphrey, Aug 18, 2013
    Last edited by a moderator: Apr 20, 2017
    Make sure you change the ownership restore command from:

    This
    Code:
    icacls "%windir%\winsxs\Catalogs" /setowner "NT Service\TrustedInstaller" /T /C
    to this:
    Code:
    icacls "%programfiles%\WindowsApps" /setowner "NT Service\TrustedInstaller" /T /C
    Also, @Ron1958, open a command prompt and type:

    Code:
    wmic os get version
    and post back the info you get.

    @1337chaos: You should put in a version check that uses the bit of code i told ron1958 to run. When it is ran, you either get back 6.2.9200 if on Windows 8 or 6.3.#### if on Windows 8.1.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. Ron1958

    Ron1958 MDL Junior Member

    Feb 21, 2010
    55
    1
    0
    6.2.9200

    Thank You for all of the help.
     

    Attached Files:

  13. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #93 s1ave77, Aug 19, 2013
    Last edited by a moderator: Apr 20, 2017
    Easiest way would be:
    Code:
    REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion | FINDSTR 6.2 >NUL
        IF %ERRORLEVEL% NEQ 0 ( 
            echo Feature is only supported on Windows 8^!
            pause
            goto :Exit       
            )
    
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,466
    990
    60
    In none of these replies do I see the actual problem.

    Explain, in detail, what part isn't working.

    Which batch file is causing the issue?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,466
    990
    60
    #95 Humphrey, Aug 19, 2013
    Last edited by a moderator: Apr 20, 2017
    Or

    Code:
    ver | FINDSTR 6.2 >NUL
    IF %ERRORLEVEL% NEQ 0 ( 
            echo Feature is only supported on Windows 8^!
            pause
            goto :Exit       
            )
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. Ron1958

    Ron1958 MDL Junior Member

    Feb 21, 2010
    55
    1
    0
    I still see all of the adds.
    The videos to get an extra deal.
     
  17. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,466
    990
    60
    When you run the batch files. You run, take own first and adremove last as you've said. Does take own show any errors, what about adremove?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. Ron1958

    Ron1958 MDL Junior Member

    Feb 21, 2010
    55
    1
    0
    No, there are no errors listed.
    That's why I don't understand why it's not working.
     
  19. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,466
    990
    60
    #99 Humphrey, Aug 19, 2013
    Last edited by a moderator: Apr 20, 2017
    Goto folder options, the view tab, then change hidden files and folders to show.
    Right click on adremove.bat and change @ECHO OFF to @ECHO ON
    Run takeown again as admin and normally run adremove.bat again.

    look for file not found or errors.

    Change youe takeown.bat to this
    Code:
    CD /D %~DP0
    takeown /f "C:\Program Files\WindowsApps" /r /d y >output.log
    icacls "C:\Program Files\WindowsApps" /grant administrators:F /t >output.log
    
    upload output.log for us or just tell us what the bottom line says.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  20. Ron1958

    Ron1958 MDL Junior Member

    Feb 21, 2010
    55
    1
    0
    #100 Ron1958, Aug 19, 2013
    Last edited: Aug 19, 2013
    I hope this is what You want, I zipped the log file up, but the site says it's to large to upload.

    Successfully processed 35745 files; Failed processing 0 files

    Here is one of the adds I see.
     

    Attached Files: