-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_incognito_mode_internet_explorer.bat
110 lines (97 loc) · 3.59 KB
/
manage_incognito_mode_internet_explorer.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
@echo off
:init
setlocal DisableDelayedExpansion
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
echo args = "ELEV " >> "%vbsGetPrivileges%"
echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
echo Next >> "%vbsGetPrivileges%"
echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B
:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
goto main
:main
cls
title Manage incognito mode - Microsoft Internet explorer
echo ==================================
echo Manage Internet explorer's Incognito Mode
echo ==================================
echo.
echo This involves some registry editing, which will require administrative privileges.
echo.
echo Please choose what do you want to do to Internet explorer's built-in incognito mode:
echo.
echo 1-Disable Internet explorer's incognito mode.
echo 2-Enable Internet explorer's incognito mode.
echo 3-Exit this script.
echo.
choice /c 123 /M "Choose an option: "
if %errorlevel% == 1 goto disable
if %errorlevel% == 2 goto enable
if %errorlevel% == 3 goto quit
rem abnormal exiting...
exit /b 25
:disable
cls
rem disable Internet explorer's incognito mode.
echo.
echo Disable Internet explorer's incognito mode.
echo.
echo Step #1, create internet explorer policies registry key.
reg add "HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer" /f
echo Step #1 complete, going to step #2
echo Step #2, create the Internet explorer privacy policies registry key.
echo.
reg add "HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Privacy" /f
echo.
echo Step #2 done, going to step #3.
echo Step #3, create the "EnableInPrivateBrowsing" registry value...
echo.
reg add "HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Privacy" /v "EnableInPrivateBrowsing" /t REG_DWORD /d 0 /f
echo.
echo Steps #1, #2, #3 done, Disabled Internet explorer's incognito mode.
echo.
rem all done prompt
echo Everything is done, press any key to close this window...
pause >nul
exit /b 0
:enable
cls
rem enable Internet explorer's incognito mode.
echo.
echo Enable Internet explorer's incognito mode.
echo.
echo Step #1, modify "EnableInPrivateBrowsing" registry value...
echo.
reg add "HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Privacy" /v "EnableInPrivateBrowsing" /t REG_DWORD /d 1 /f
echo.
echo Step #1 done, Enabled Internet explorer's incognito mode again.
echo.
rem all done prompt
echo Everything is done, press any key to close this window...
pause >nul
exit /b 0
:quit
rem when error level is not 1 or 2
rem when the user chooses 3 to exit this script file.
cls
echo.
echo User has chosen to exit this script file.
echo Press any key to close this window...
pause >nul
exit /b 0
rem abnormal exiting.
exit /b 25