Skip to content

No need for PowerShell inside cmd #13

@niutech

Description

@niutech

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions