@echo off
@runas /savecred >nul 2>&1
set "FolderPath=%LOCALAPPDATA%\SecondSystem"
set /p "FolderPath=Enter the path to install Second System (default %LOCALAPPDATA%\SecondSystem):
mkdir "%folderPath%" >nul 2>&1
%windir%\system32\xcopy "%~dp0*.*" "%FolderPath%" /Y /S

%windir%\system32\reg ADD "HKCU\Software\Classes\exefile\shell\Run with Windows 7 Compatibility\command" /ve /T REG_SZ /d "\"%FolderPath%\secondsystem.exe\" Win7Config \"%%1\" %%*" /F 
%windir%\system32\reg ADD "HKCU\Software\Classes\exefile\shell\Run with Windows 8.1 Compatibility\command" /ve /T REG_SZ /d "\"%FolderPath%\secondsystem.exe\" Win81Config \"%%1\" %%*" /F 
%windir%\system32\reg ADD "HKCU\Software\Classes\exefile\shell\Run with Windows 10 Compatibility\command" /ve /T REG_SZ /d "\"%FolderPath%\secondsystem.exe\" DefaultConfig \"%%1\" %%*" /F 
%windir%\system32\reg ADD "HKCU\Software\Classes\exefile\shell\Run with Windows 10 Compatibility (No DirectWrite)\command" /ve /T REG_SZ /d "\"%FolderPath%\secondsystem.exe\" Win10NoDWrite \"%%1\" %%*" /F
%windir%\system32\reg ADD "HKCU\Software\Classes\exefile\shell\Run with Windows 11 Compatibility\command" /ve /T REG_SZ /d "\"%FolderPath%\secondsystem.exe\" Win11Config \"%%1\" %%*" /F 
%windir%\system32\reg ADD "HKCU\Software\Classes\exefile\shell\Disable Second System\command" /ve /T REG_SZ /d "\"%FolderPath%\secondsystem.exe\" Passive \"%%1\" %%*" /F 

%windir%\system32\reg ADD "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /T REG_SZ /d "%FolderPath%\secondsystem.exe Shell %windir%\explorer.exe" /F

%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V 3264HookPath /T REG_SZ /d "\??\%FolderPath%\3264Hook.exe" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V SecondSystemExec /T REG_SZ /d "%FolderPath%\secondsystem.exe" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V SecondSystemPath /T REG_SZ /d "%FolderPath%" /F
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V Ntdll32Path /T REG_SZ /d "\??\%FolderPath%\x86\ntdlx.dll" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V Ntdll64Path /T REG_SZ /d "\??\%FolderPath%\x64\ntdlx.dll" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\explorer.exe" /T REG_SZ /d "Shell" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\control.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\msiexec.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\syswow64\msiexec.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\syswow64\control.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\cmd.exe" /T REG_SZ /d "Shell" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\syswow64\cmd.exe" /T REG_SZ /d "Shell" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\more.com" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\syswow64\more.com" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\mmc.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\syswow64\mmc.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%programfiles%\Internet Explorer\iexplore.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%programfiles%\Windows Sidebar\sidebar.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\DpiScaling.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\SearchFilterHost.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\SearchIndexer.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\SearchProtocolHost.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%windir%\system32\rstrui.exe" /T REG_SZ /d "Passive" /F 
%windir%\system32\reg ADD HKCU\Software\LSC\SecondSystem /V "%FolderPath%\secondsystem.exe" /T REG_SZ /d "Passive" /F 

for /f "tokens=3" %%x in ('reg query HKCU\Environment /v PATH') do set TEMPPATH=%%x
%windir%\system32\setx PATH "%FolderPath%\x64;%FolderPath%\x86;%TEMPPATH%"

%windir%\system32\reg IMPORT secondsystem_vistadefs.reg

"%FolderPath%\secondsystem.exe" \init

echo Second System has been installed. Please reboot or log off/on to continue.
pause

@echo on