Windows 10: Telemetry & Application Data List

Discussion in 'Windows 10' started by Smorgan, Oct 8, 2014.

  1. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,389
    11,614
    240
    The "ECHO is off." lines seem to be when the parsing encounters a blank line with no text. I'll see if I can mess with the EOL stuff and figure that out.
    On the other non-copied stuff, I think I need to refine the logic in the parse so that it will only omit the lines that have "%1 %2" in them.
     
  2. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,389
    11,614
    240
    #102 murphy78, Oct 16, 2014
    Last edited by a moderator: Apr 20, 2017
    hosts file cmd script parsing functions

    OK I got the hosts parsing functions working correctly:
    Code:
    @echo off
    
    
    call :Add-Hosts-Line-Function 0.0.0.0 someip.address.com
    pause
    call :Remove-Hosts-Line-Function 0.0.0.0 someip.address.com
    pause
    call :flushdns
    goto :eof
    
    
    :Add-Hosts-Line-Function
    IF %1 EQU "" echo :Add-Hosts-Line-Function missing 1st parameter&pause&exit
    IF %2 EQU "" echo :Add-Hosts-Line-Function missing 2nd parameter&pause&exit
    
    
    :make copy to work with since system won't let you directly edit hosts file
    attrib -h -s "%WinDir%\System32\drivers\etc\hosts" >nul
    xcopy /chy "%WinDir%\System32\drivers\etc\hosts" "%TMP%" >nul
    del /q/f "%WinDir%\System32\drivers\etc\hosts" >nul
    
    
    for /f "delims=" %%h in ('type "%TMP%\hosts" ^| find /c /i "%2"') do (
        set "result=%%h" >nul
        )
    
    
    if "%result%"=="0" (
        >>"%TMP%\hosts" echo %1 %2
        echo %1 %2 added to hosts file
        move /y "%TMP%\hosts" "%WinDir%\System32\drivers\etc\hosts" >nul
        attrib +h "%WinDir%\System32\drivers\etc\hosts" >nul
        exit /b
        ) else (
        echo %2 already exists in hosts file
        del /q/f "%TMP%\hosts" >nul
        exit /b
        )
    ::end function
    
    
    :Remove-Hosts-Line-Function
    IF %1 EQU "" echo :Remove-Hosts-Line-Function missing 1st parameter&pause&exit
    IF %2 EQU "" echo :Remove-Hosts-Line-Function missing 2nd parameter&pause&exit
    
    
    :make copy to work with since system won't let you directly edit hosts file
    attrib -h -s "%WinDir%\System32\drivers\etc\hosts" >nul
    xcopy /chy "%WinDir%\System32\drivers\etc\hosts" "%TMP%" >nul
    del /q/f "%WinDir%\System32\drivers\etc\hosts" >nul
    
    
    for /f "delims=" %%h in ('type "%TMP%\hosts" ^| find /c /i "%2"') do (
        set "result=%%h" >nul
        )
    if "%result%" geq "1" (
        for /f "tokens=*" %%a in ('findstr /in ".*" "%TMP%\hosts"') do (
            echo %%a>>"%TMP%\l_1.x"
            )
        for /f "eol=# tokens=1,2 delims=:" %%a in ('findstr /i "%2" "%TMP%\l_1.x"') do (
            set stringlines=%%a
            )
        setlocal enabledelayedexpansion
        set /a "beforelines=stringlines-1"
        set /a "afterlines=stringlines+1"
        for /f "eol=# tokens=2* delims=:" %%a in ('findstr /in ".*" "%TMP%\l_1.x"') do (
            if %%a leq !beforelines! echo.%%b>>"%tmp%\l_2.x"
            if %%a geq !afterlines! echo.%%b>>"%tmp%\l_2.x"
            )
        endlocal
        move /y "%TMP%\l_2.x" "%WinDir%\System32\drivers\etc\hosts" >nul
        attrib +h "%WinDir%\System32\drivers\etc\hosts" >nul
        del /q/f "%TMP%\hosts" >nul
        del /q/f "%TMP%\*.x" >nul
        echo %2 successfully removed from hosts file
        exit /b
        ) else (
        echo %2 does not exist in hosts file
        del /q/f "%TMP%\hosts" >nul
        del /q/f "%TMP%\*.x" >nul
        exit /b
        )
    ::end function
    
    
    :flushdns
    call ipconfig /flushdns >nul
    exit /b
    The relevant parts are the functions:
    :Add-Hosts-Line-Function
    :Remove-Hosts-Line-Function
    :flushdns

    The add and remove lines are pretty self-explanatory... the first argument passed is the numeric IP address to pass to the function. The 2nd is the alphabetical dns version of the ip.
    The :flushdns does not take variables, it just runs a ipconfig /flushdns
    If you can remember to use ipconfig /flushdns in your scripts you won't need to copy the function and call it.

    Example calls for the add and remove functions are in the script.
    Enjoy guys.
     

    Attached Files:

  3. TONSCHUH

    TONSCHUH MDL Addicted

    Jun 11, 2012
    816
    287
    30
    #103 TONSCHUH, Oct 16, 2014
    Last edited by a moderator: Apr 20, 2017
    Awesome job !

    :good3:
     
  4. Smorgan

    Smorgan Glitcher

    Mar 25, 2010
    1,855
    1,051
    60
    Looks good!

    I've been busy trying to figure out how to install a program with a silent switch under powershell.
     
  5. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,389
    11,614
    240
    Ahh yes, that is one limitation of this kind of processing... The findstr /in function numbers each line something like this:
    1:0.0.0.0 blahblahblah.ipaddress.com

    So it remembers the line by searching each line for the colon.
    colons are not usually found in the hosts file, so it's typically a safe way to process them.

    The -3 to +1 part was changed to -1 to +1 because in the original script, it added 3 lines, so it was their way of keeping track of how much was removed.

    The way the echo status was fixed was by changing the part where it says echo %%b>> etc to echo.%%b>>
    When you "echo." It's basically an empty line. When the %%b contains no data, it will not add anything.
    When %%b does contain data, it will add the data.

    If you wanted to retain the ::1 localhost line, hmm... I dunno what to say... The entire way the script works would have to be re-done.
    If it's that important, I'd say one of the vbscript or powershell scripts would probably be better since you don't have to mess with delims when parsing.
     
  6. Smorgan

    Smorgan Glitcher

    Mar 25, 2010
    1,855
    1,051
    60
    Natural progression of this idea.

    Murphy I think we should bundle this into an OEM pack to execute while the install is taking place or post install.

    This would be for testing purposes to see if it could be done for future copies of Windows 10.
     
  7. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,389
    11,614
    240
    go for it bud, just call the functions with the appropriate numbers like 0.0.0.0 vortex.microsoft.blahblahblah, etc
    just gotta copy/paste the functions into the enable/disable script stuff and change it to remove the enable stuff and any sort of input.

    Obviously, this would really only be for a VM as for a live machine, you'd want another script to re-enable stuff in case it was required for updating.
     
  8. Smorgan

    Smorgan Glitcher

    Mar 25, 2010
    1,855
    1,051
    60
    We could accomplish that via a shortcut in the start menu or desktop icon.

    Disable Microsoft Tracking

    Enable Microsoft Tracking
     
  9. Smorgan

    Smorgan Glitcher

    Mar 25, 2010
    1,855
    1,051
    60
    Ok Kicked the Scripting over to the OP!

    1.05 - Tracking Wiz
     
  10. KnowledgeableNewbie

    KnowledgeableNewbie MDL Member

    Sep 30, 2014
    178
    28
    10
    no i didn't mean that. it's not important. easy enough to edit manually. here's a little something i whipped based on your script for those that want it. feel free to edit it as you see fit. it's a work in progress, since i'm not a coder.
     

    Attached Files:

  11. KnowledgeableNewbie

    KnowledgeableNewbie MDL Member

    Sep 30, 2014
    178
    28
    10
    lol. i messed around with that line for a while and didn't think of adding the ".". sometimes the smallest things elude us.
     
  12. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. Smorgan

    Smorgan Glitcher

    Mar 25, 2010
    1,855
    1,051
    60
    Ya I stopped tracking the thread for a bit to make the Powershell Script work. I started working on learning how to do Powershell less than a week ago :p
     
  14. Smorgan

    Smorgan Glitcher

    Mar 25, 2010
    1,855
    1,051
    60
    At the moment I'm waiting to fix 1.09 so that we have full system privileges to disable dmwappushsvc because at the moment we can't
     
  15. Smorgan

    Smorgan Glitcher

    Mar 25, 2010
    1,855
    1,051
    60
    Ok I'm putting out 1.09 with the registry fix which means it will require a restart at some point to stop dmwappushsvc.

    This is going to take awhile to figure out so may as well put 1.09 out for a temporary fix.
     
  16. Smorgan

    Smorgan Glitcher

    Mar 25, 2010
    1,855
    1,051
    60
    #118 Smorgan, Oct 21, 2014
    Last edited: Oct 21, 2014
    (OP)
    This will remain the Main download page for Telemetry Tracker Testing.

    The Change log will be posted on the OP as well.

    I will keep this this updated :)
     
  17. KnowledgeableNewbie

    KnowledgeableNewbie MDL Member

    Sep 30, 2014
    178
    28
    10
    when i was doing my editing and stopped diagtrack and dmwsvcappushsvc i ran WU to see if for some reason the services would restart. WU worked without a hitch and services remained stopped. haven't tried it yet after running the script. just for curiosity has anyone tried it on a live machine.
     
  18. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,389
    11,614
    240
    I meant more for updating the builds to newer versions. It would be problematic if the upgrade process was expecting services in a certain state with certain registry keys and they were completely different.
    It's more of a paranoia. I don't think MS keeps service settings during these build updates, but rather copies any "data" stored by the processes. So, it would probably revert the services back to default for the new builds, but keep any logging or telemetry data already collected. That's just my hunch though. If we ever did run into problems, people would be advised to undo the mods we made.