Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 确定计算机在域或工作组中?_Windows_Batch File - Fatal编程技术网

Windows 确定计算机在域或工作组中?

Windows 确定计算机在域或工作组中?,windows,batch-file,Windows,Batch File,是否有一种快速方法可以使用批处理脚本来确定计算机是属于域还是工作组?如果它是域的成员,那么域的名称是什么 最后,我能够使用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-WmiObj

是否有一种快速方法可以使用批处理脚本来确定计算机是属于
还是
工作组
?如果它是
的成员,那么
的名称是什么

最后,我能够使用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