text
stringlengths
0
834k
:: Thanks to @abbodi1406 for the powershell method and solving special characters issue in file path name.
%nul% reg query HKU\S-1-5-19 && (
goto :Passed
) || (
if defined _elev goto :E_Admin
)
set ""_batf=%~f0""
set ""_vbsf=%temp%\admin.vbs""
set _PSarg=""""""%~f0"""""" -el
if defined _args set _PSarg=""""""%~f0"""""" -el """"""%_args%""""""
setlocal EnableDelayedExpansion
(
echo Set strArg=WScript.Arguments.Named
echo Set strRdlproc = CreateObject^(""WScript.Shell""^).Exec^(""rundll32 kernel32,Sleep""^)
echo With GetObject^(""winmgmts:\\.\root\CIMV2:Win32_Process.Handle='"" ^& strRdlproc.ProcessId ^& ""'""^)
echo With GetObject^(""winmgmts:\\.\root\CIMV2:Win32_Process.Handle='"" ^& .ParentProcessId ^& ""'""^)
echo If InStr ^(.CommandLine, WScript.ScriptName^) ^<^> 0 Then
echo strLine = Mid^(.CommandLine, InStr^(.CommandLine , ""/File:""^) + Len^(strArg^(""File""^)^) + 8^)
echo End If
echo End With
echo .Terminate
echo End With
echo CreateObject^(""Shell.Application""^).ShellExecute ""cmd.exe"", ""/c "" ^& chr^(34^) ^& chr^(34^) ^& strArg^(""File""^) ^& chr^(34^) ^& strLine ^& chr^(34^), """", ""runas"", 1
)>""!_vbsf!""
(%nul% cscript //NoLogo ""!_vbsf!"" /File:""!_batf!"" -el ""!_args!"") && (
del /f /q ""!_vbsf!""
exit /b
) || (
del /f /q ""!_vbsf!""
%nul% %_psc% ""start cmd.exe -arg '/c \""!_PSarg:'=''!\""' -verb runas"" && (
exit /b
) || (
goto :E_Admin
)
)
exit /b
:E_Admin
%ELine%
echo This script require administrator privileges.
echo To do so, right click on this script and select 'Run as administrator'.
set _end=1
goto Done
:Passed
::========================================================================================================================================
:: Fix for the special characters limitation in path name
:: Written by @abbodi1406
set ""_work=%~dp0""
if ""%_work:~-1%""==""\"" set ""_work=%_work:~0,-1%""
set ""_batf=%~f0""
set ""_batp=%_batf:'=''%""
setlocal EnableDelayedExpansion
::========================================================================================================================================
if not exist ""!_work!\Activate.cmd"" (
%ELine%
echo File [Activate.cmd] does not exist in current folder..
echo It's required for the Task Creation.
set _end=1
goto Done
)
call :check cleanosppx64.exe cleanosppx86.exe
if defined _miss set _end=1&goto Done
::========================================================================================================================================
set ""_dest=%ProgramData%\Online_KMS_Activation""
set ""key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks""
:ActivationRenewal
cls
title Online KMS Activation Renewal
mode con cols=98 lines=30
set ActTask=
set error_=
set DelDeskCont=
set error_1=
if defined RenTask goto:Task
if defined RenActTask set ActTask=1&goto:Task
if defined DeskMenu goto:ContextMenu
echo:
echo:
echo:
echo You can apply the option [either 1 or 2] and [3].
echo ______________________________________________________