I've been trying to make a batch file to disable or enable cortana in windows 10. I do 1, the cortana process is only suspended, not closed and as a consequence it doesn't rename the file. What have I done wrong? I have asked for admin permissions, can anyone help?
PS - I tried taskkill /g /im SearchUI.exe
but the same results were reproduced.
@echo off
color 2
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
echo 1. Disable Cortana
echo 2. Enable Cortana
echo .
CHOICE /C 12 /M "Which one would you like to do?"
If ErrorLevel 2 GOTO EnableCortana
If ErrorLevel 1 GOTO DisableCortana
:EnableCortana
Echo "Enabling Cortana..." (
ren C:\Windows\SystemApps\Microsoft.Windows.CortanaDISABLED_cw5n1h2txyewy Microsoft.Windows.Cortana_cw5n1h2txyewy
)
GOTO End
:Disable Cortana
Echo "Disabling Cortana..." (
taskkill /im SearchUI.exe
ren C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy Microsoft.Windows.CortanaDISABLED_cw5n1h2txyewy
)
GOTO End