无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
查看: 4251|回复: 7
打印 上一主题 下一主题

[求助] 有懂批处理的大佬吗,有个脚本需要键盘输入Y能帮我改下吗

[复制链接]
1#
发表于 2020-2-12 12:32:10 | 显示全部楼层
(免下载!)附件的源码:
  1. @rem OneDrive Complete uninstaller batch process for Windows 10.
  2. @rem Run as administrator to completely delete all OneDrive components and files.
  3. @rem Written by TERRA Operative - 2016/08/31. V1.2
  4. @rem Feel free to distribute freely as long as you leave this entire file unchanged and intact,
  5. @rem and if you do make changes and adaptions, don't be a dick about attributing where due.
  6. @rem And most importantly, peace out and keep it real.

  7. @echo OFF

  8. @REM Set variables for coloured text
  9. SETLOCAL EnableDelayedExpansion
  10. for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do     rem"') do (
  11.   set "DEL=%%a"
  12. )

  13.    echo ------Windows 10 OneDrive Uninstaller V1.2------
  14.    echo.
  15.    
  16. @rem This code block detects if the script is being running with admin privileges. If it isn't it pauses and then quits.
  17. NET SESSION >nul 2>&1
  18. IF %ERRORLEVEL% EQU 0 (


  19.    echo        Administrator Privileges Detected!
  20.    echo.
  21. ) ELSE (

  22.    echo.
  23.    call :colorEcho 0C "########### ERROR - ADMINISTRATOR PRIVILEGES REQUIRED #############"
  24.    echo.
  25.    call :colorEcho 0C "#                                                                 #"
  26.    echo.
  27.    call :colorEcho 0C "#"
  28.    call :colorEcho 07 "    This script must be run as administrator to work properly."
  29.    call :colorEcho 0C "    #"
  30.    echo.
  31.    call :colorEcho 0C "#"
  32.    call :colorEcho 07 "    If you're seeing this after clicking on a start menu icon,"
  33.    call :colorEcho 0C "   #"
  34.    echo.
  35.    call :colorEcho 0C "#"
  36.    call :colorEcho 07 "  then right click on the file and select 'Run As Administrator'"
  37.    call :colorEcho 0C " #"
  38.    echo.
  39.    call :colorEcho 0C "#                                                                 #"
  40.    echo.
  41.    call :colorEcho 0C "###################################################################"
  42.    echo.
  43.    echo.

  44.    PAUSE
  45.    EXIT /B 1
  46. )

  47.    echo -----------------------------------------------
  48.    call :colorEcho 0C "                    WARNING"
  49.    echo.
  50.    call :colorEcho 0C "  This script will completely and permanently"
  51.    echo.
  52.    call :colorEcho 0C "      remove OneDrive from your computer."
  53.    echo.
  54.    call :colorEcho 0C "        Make sure all OneDrive documents"   
  55.    echo.
  56.    call :colorEcho 0C "       that are stored locally are fully"
  57.    echo.
  58.    call :colorEcho 0C "          backed up before proceeding."   
  59.    echo.
  60.    echo -----------------------------------------------
  61.    echo.

  62.    SET /P M=  Press 'Y' to continue or any other key to exit.
  63.         if %M% ==Y goto PROCESSKILL
  64.         if %M% ==y goto PROCESSKILL

  65.    EXIT /B 1


  66. @rem The following is based on info from here written by 'LK':
  67. @rem https://techjourney.net/disable-or-uninstall-onedrive-completely-in-windows-10/


  68. @rem Terminate any OneDrive process
  69. :PROCESSKILL
  70.    echo.
  71.    echo Terminating OneDrive process.
  72.    
  73. taskkill /f /im OneDrive.exe


  74. @rem Detect if OS is 32 or 64 bit
  75. reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT

  76. if %OS%==32BIT GOTO 32BIT
  77. if %OS%==64BIT GOTO 64BIT


  78. @rem Uninstall OneDrive app
  79. :32BIT
  80.    echo.
  81.    echo This is a 32-bit operating system.
  82.    echo Removing OneDrive setup files.
  83.    
  84. %SystemRoot%\System32\OneDriveSetup.exe /uninstall
  85. GOTO CLEAN

  86. :64BIT
  87.    echo.
  88.    echo This is a 64-bit operating system.
  89.    echo Removing OneDrive setup files.
  90.    
  91. %SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall
  92. GOTO CLEAN


  93. @rem Clean and remove OneDrive remnants
  94. :CLEAN
  95.    echo.
  96.    echo Removing remaining OneDrive folders.
  97.    
  98.    rd "%UserProfile%\OneDrive" /Q /S
  99.    rd "%LocalAppData%\Microsoft\OneDrive" /Q /S
  100.    rd "%ProgramData%\Microsoft OneDrive" /Q /S
  101.    rd "C:\OneDriveTemp" /Q /S
  102.    
  103.    echo.
  104.    call :colorEcho 0C "If you see 'access denied' errors here, reboot and run this batch file again."
  105.    echo.



  106. @rem Delete and remove OneDrive in file explorer folder tree registry key
  107.    echo.
  108.    echo Removing OneDrive registry keys.
  109.    
  110.    IF EXIST "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" REG Delete "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
  111.    IF EXIST "HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" REG Delete "HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
  112.    REG ADD "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /v System.IsPinnedToNameSpaceTree /d "0" /t REG_DWORD /f
  113.    
  114.    echo.
  115.    echo OneDrive Uninstall and cleaning completed.
  116.    echo.

  117.    PAUSE
  118.    echo So long and thanks for all the fish...
  119.    PING -n 2 127.0.0.1>nul
  120.    EXIT /B 1

  121.    
  122. @rem Settings for text colour

  123. :colorEcho
  124. echo off
  125. <nul set /p ".=%DEL%" > "%~2"
  126. findstr /v /a:%1 /R "^$" "%~2" nul
  127. del "%~2" > nul 2>&1i
复制代码
回复

使用道具 举报

2#
发表于 2020-2-12 12:34:39 | 显示全部楼层
不用思考的将 71行改为:
SET M=Y

点评

谢谢大神!确实管用!  详情 回复 发表于 2020-2-12 13:46
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-6-7 01:20

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表