0

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
Decallion
  • 1
  • 1
  • This seems more like a question best suited for [server fault](http://serverfault.com/), but if you're looking to apply this on multiple machines, i'd look into using group policy to do the job, there are policies that can disable Cortana without crippling the ability to search for programs. See in group policy editor under Computer Configuration -> Administrative templates -> Windows components -> Search. – Andrew Pilley Aug 29 '15 at 21:36
  • I'd say that would be hard to do from my perspective, as cortana keeps re-appearing as a process and it wouldn't take any changes. What I don't get is why does it only suspend when ive got `taskkill` and admin permision, rather than close completely. The rest should be working. – Decallion Aug 30 '15 at 04:11
  • the searchUI process also handles searching the start menu and your local indexed files even if cortana is disabled. If you could kill it completely, you'll lose the ability to hit the Windows key and type the name of an app, I'm pretty sure. – Andrew Pilley Aug 30 '15 at 07:02
  • I am aware of that and very willing to go through with the process... – Decallion Aug 30 '15 at 13:46

0 Answers0