So, I was working on a GUI written in Batch only, for a project at school. now that I coded the GUI, it needs to be replaced with the "explorer.exe" located in "C:\Windows" and NO. I am not talking about "iexplorer.exe". nowhere is my question: How do I delete (I have a backup) the explorer.exe in batch code only? (with admin permissions). just "taskkill /f /im explorer.exe" and "del C:\Windows\explorer.exe /f" dosen't work, because it just returns "Access Denied". anyone a suggestion how to do it?
1 Answer
You must to change ownership and permissions of explore.exe file to do that one succesfull.
Create a file called script.bat somewhere, in that case I created in C:\script.bat with the following content:
echo off
taskkill /f /im explorer.exe
takeown /a /f C:\Windows\explorer.exe
icacls C:\Windows\explorer.exe /grant administrators:f
del C:\Windows\explorer.exe
Run Task Scheduler by cmd taskschd.msc /s
Go to Create Task ...
Enter Name: field with ScriptTask
Left click on Run whether user is logged on or not
Check Do not store password. The Task will only have access to local computer resources.
Check Run with highest privileges
Go to Triggers tab
Left click on New...
Change Begin the task to At startup
Go to Actions tab
Left click on New...
Enter Program/script: field with C:\script.bat
Left click on OK
Left click on OK again
Then, restart your machine by cmd shutdown /t 0 /r
The script will delete the explorer.exe file sucessfully during the system startup.
References:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
?.reg
file it dosen`t work, or replacing it using batch only isn't an option