Open niutech opened 4 months ago
You don't need to invoke yet another shell inside shell - PowerShell inside cmd. You can check Windows version:
for /f "tokens=4 delims=. " %%i in ('ver') do set VERSION=%%i
instead of:
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile "If ($([System.Environment]::OSVersion.Version.Major) -GE '10') { Exit 0 } Else { Exit 1 }"
Next, you cna check if Windows is a part of domain:
for /f "tokens=2 delims==" %a in ('wmic computersystem get PartOfDomain /value') do set ComMem=%a
for /f %%a in ('powershell "(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain"') do set ComMem=%%a
Also you don't need @ before setlocal since the first line is @echo off.
setlocal
@echo off
Thank you very much for your feedback for the alternative method! I've been bit busy with other things, but I'll include your changes in the next revision!
You don't need to invoke yet another shell inside shell - PowerShell inside cmd. You can check Windows version:
instead of:
Next, you cna check if Windows is a part of domain:
instead of:
Also you don't need @ before
setlocal
since the first line is@echo off
.