diff options
| author | WindowsAddict <[email protected]> | 2025-02-24 00:36:35 +0530 |
|---|---|---|
| committer | WindowsAddict <[email protected]> | 2025-02-24 00:36:35 +0530 |
| commit | ab0cd24f89f5b16a35cc7a685b59d5fe5460289d (patch) | |
| tree | 701b84a1a148730991098f9fd07f0bec1015ddb0 /MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd | |
| parent | 55afa30fcd9147fe54ad1a85193e9777df2bb63b (diff) | |
| download | Microsoft-Activation-Scripts-ab0cd24f89f5b16a35cc7a685b59d5fe5460289d.zip | |
Add more checks for powershell
Diffstat (limited to 'MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd')
| -rw-r--r-- | MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd b/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd index a1679e1..53860bd 100644 --- a/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd +++ b/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd @@ -228,11 +228,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst
-for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a)
+for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a)
-if /i "%tstresult%"=="ConstrainedLanguage" (
+if /i not "%tstresult%"=="FullLanguage" (
+%eline%
+echo %tstresult%
+cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
+
+REM check LanguageMode
+
+cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
%eline%
-echo ConstrainedLanguage mode found in PowerShell. Aborting...
+echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
@@ -240,10 +247,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done
)
-if /i not "%tstresult%"=="FullLanguage" (
-%eline%
-echo "%tstresult%"
-cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
+REM check Powershell core version
+
+cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
+echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
+goto dk_done
+)
+
+REM check antivirus and other errors
+
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
|
