Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No need for PowerShell inside cmd #13

Open
niutech opened this issue Jun 27, 2024 · 1 comment
Open

No need for PowerShell inside cmd #13

niutech opened this issue Jun 27, 2024 · 1 comment

Comments

@niutech
Copy link

niutech commented Jun 27, 2024

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

instead of:

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.

@TheBobPony
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants