2016-07-21 77 views

回答

0

最後,我能夠用powershell找到它,並捕獲它在批處理變量中的輸出。

以下是代碼

@echo off 
REM Bellow logic is to identify "Computer membership"? True=Member of domain | False=Member of Workgroup 
for /f %%a in ('powershell "(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain"') do set ComMem=%%a 
echo %ComMem% 

If %ComMem% Equ True (
         GoTo Domainmember 
         ) Else (
           GoTo WorkgroupMember 
           ) 


REM Bellow logic is will find Domain/Workgroup Name 

:Domainmember 

for /f %%f in ('powershell "(Get-WmiObject Win32_ComputerSystem).Domain"') do set MemNme=%%f 
Pause 
GoTo End 
:WorkgroupMember 
for /f %%f in ('powershell "(Get-WmiObject Win32_ComputerSystem).Workgroup"') do set MemNme=%%f 

:End 
Echo %MemNme% 
pause 
相關問題