Home All Groups Group Topic Archive Search About

how do I disjoin a machine to workgroup name

Author
4 May 2009 10:22 PM
Joey
how do I modify the below to join a workgroup name "workgroup" instead of
the domain name?

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
strDomain = objComputer.Domain
intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)

Author
5 May 2009 3:42 PM
Alex K. Angelopoulos
First, is the computer currently a domain member, not a workgroup member? If
so - and only if so - you first need to use the UnjoinDomainOrWorkgroup the
way you have it.

The second step is to use JoinDomainOrWorkgroup, like this:

objComputer.JoinDomainOrWorkgroup("workgroup")


you have the necessary privileges, don't bother with arguments

Show quoteHide quote
"Joey" <j***@joey.com> wrote in message
news:eIAv$aQzJHA.1372@TK2MSFTNGP05.phx.gbl...
> how do I modify the below to join a workgroup name "workgroup" instead of
> the domain name?
>
> Set objNetwork = CreateObject("WScript.Network")
> strComputer = objNetwork.ComputerName
> Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"
> & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer &
> "'")
> strDomain = objComputer.Domain
> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>
Author
6 May 2009 7:18 PM
Joey
ok

how do I add a line that will kill all processes ?

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
'strDomain = objComputer.Domain
intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
intReturn1 = objComputer.JoinDomainOrWorkgroup("workgroup")


Set OpSysSet = GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery _
("select * from Win32_OperatingSystem where Primary=true")

for each OpSys in OpSysSet
OpSys.Reboot()
next



Show quoteHide quote
"Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
news:%23cOJpgZzJHA.6004@TK2MSFTNGP02.phx.gbl...
> First, is the computer currently a domain member, not a workgroup member?
> If so - and only if so - you first need to use the UnjoinDomainOrWorkgroup
> the way you have it.
>
> The second step is to use JoinDomainOrWorkgroup, like this:
>
> objComputer.JoinDomainOrWorkgroup("workgroup")
>
>
> you have the necessary privileges, don't bother with arguments
>
> "Joey" <j***@joey.com> wrote in message
> news:eIAv$aQzJHA.1372@TK2MSFTNGP05.phx.gbl...
>> how do I modify the below to join a workgroup name "workgroup" instead of
>> the domain name?
>>
>> Set objNetwork = CreateObject("WScript.Network")
>> strComputer = objNetwork.ComputerName
>> Set objComputer =
>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer &
>> "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
>> strDomain = objComputer.Domain
>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>
Author
7 May 2009 7:07 PM
Alex K. Angelopoulos
Since you're using the Reboot() method, that will happen automatically. Are
you running into problems with making this work in a specific situation?

Show quoteHide quote
"Joey" <j***@joey.com> wrote in message
news:euFxo9nzJHA.1492@TK2MSFTNGP04.phx.gbl...
> ok
>
> how do I add a line that will kill all processes ?
>
> Set objNetwork = CreateObject("WScript.Network")
> strComputer = objNetwork.ComputerName
> Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"
> & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer &
> "'")
> 'strDomain = objComputer.Domain
> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
> intReturn1 = objComputer.JoinDomainOrWorkgroup("workgroup")
>
>
> Set OpSysSet = GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery
> _
> ("select * from Win32_OperatingSystem where Primary=true")
>
> for each OpSys in OpSysSet
> OpSys.Reboot()
> next
>
>
>
> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
> news:%23cOJpgZzJHA.6004@TK2MSFTNGP02.phx.gbl...
>> First, is the computer currently a domain member, not a workgroup member?
>> If so - and only if so - you first need to use the
>> UnjoinDomainOrWorkgroup the way you have it.
>>
>> The second step is to use JoinDomainOrWorkgroup, like this:
>>
>> objComputer.JoinDomainOrWorkgroup("workgroup")
>>
>>
>> you have the necessary privileges, don't bother with arguments
>>
>> "Joey" <j***@joey.com> wrote in message
>> news:eIAv$aQzJHA.1372@TK2MSFTNGP05.phx.gbl...
>>> how do I modify the below to join a workgroup name "workgroup" instead
>>> of the domain name?
>>>
>>> Set objNetwork = CreateObject("WScript.Network")
>>> strComputer = objNetwork.ComputerName
>>> Set objComputer =
>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer &
>>> "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
>>> strDomain = objComputer.Domain
>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>>
>
>
Author
9 May 2009 11:58 PM
Joey
yes after joining the domain, there isa process that keeps hanging and
waiting for a "end now". I want to be able to kill that process and then
reboot

Show quoteHide quote
"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
wrote in message news:upPFJc0zJHA.5032@TK2MSFTNGP05.phx.gbl...
> Since you're using the Reboot() method, that will happen automatically.
> Are you running into problems with making this work in a specific
> situation?
>
> "Joey" <j***@joey.com> wrote in message
> news:euFxo9nzJHA.1492@TK2MSFTNGP04.phx.gbl...
>> ok
>>
>> how do I add a line that will kill all processes ?
>>
>> Set objNetwork = CreateObject("WScript.Network")
>> strComputer = objNetwork.ComputerName
>> Set objComputer =
>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer &
>> "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
>> 'strDomain = objComputer.Domain
>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>> intReturn1 = objComputer.JoinDomainOrWorkgroup("workgroup")
>>
>>
>> Set OpSysSet =
>> GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery _
>> ("select * from Win32_OperatingSystem where Primary=true")
>>
>> for each OpSys in OpSysSet
>> OpSys.Reboot()
>> next
>>
>>
>>
>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>> news:%23cOJpgZzJHA.6004@TK2MSFTNGP02.phx.gbl...
>>> First, is the computer currently a domain member, not a workgroup
>>> member? If so - and only if so - you first need to use the
>>> UnjoinDomainOrWorkgroup the way you have it.
>>>
>>> The second step is to use JoinDomainOrWorkgroup, like this:
>>>
>>> objComputer.JoinDomainOrWorkgroup("workgroup")
>>>
>>>
>>> you have the necessary privileges, don't bother with arguments
>>>
>>> "Joey" <j***@joey.com> wrote in message
>>> news:eIAv$aQzJHA.1372@TK2MSFTNGP05.phx.gbl...
>>>> how do I modify the below to join a workgroup name "workgroup" instead
>>>> of the domain name?
>>>>
>>>> Set objNetwork = CreateObject("WScript.Network")
>>>> strComputer = objNetwork.ComputerName
>>>> Set objComputer =
>>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer
>>>> & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
>>>> strDomain = objComputer.Domain
>>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>>>
>>
>>
Author
10 May 2009 8:56 PM
Alex K. Angelopoulos
Instead of using Win32_OperatingSystem's Reboot() method, you're probably
better off using its Win32Shutdown; this allows you forced shutdown (trying
to kill all processes isn't going to work - it will kill your own script as
well, and some processes won't be touched).

You want to specify restart + forcing, which is a value of 6 if you check
the online documentation for the method:

http://msdn.microsoft.com/en-us/library/aa394058%28VS.85%29.aspx

so use it like this:
    OpSys.Win32Shutdown( 6, 0)


Show quoteHide quote
"Joey" <j***@joey.com> wrote in message
news:#A$bDIQ0JHA.2300@TK2MSFTNGP06.phx.gbl...
> yes after joining the domain, there isa process that keeps hanging and
> waiting for a "end now". I want to be able to kill that process and then
> reboot
>
> "Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
> wrote in message news:upPFJc0zJHA.5032@TK2MSFTNGP05.phx.gbl...
>> Since you're using the Reboot() method, that will happen automatically.
>> Are you running into problems with making this work in a specific
>> situation?
>>
>> "Joey" <j***@joey.com> wrote in message
>> news:euFxo9nzJHA.1492@TK2MSFTNGP04.phx.gbl...
>>> ok
>>>
>>> how do I add a line that will kill all processes ?
>>>
>>> Set objNetwork = CreateObject("WScript.Network")
>>> strComputer = objNetwork.ComputerName
>>> Set objComputer =
>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer &
>>> "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
>>> 'strDomain = objComputer.Domain
>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>> intReturn1 = objComputer.JoinDomainOrWorkgroup("workgroup")
>>>
>>>
>>> Set OpSysSet =
>>> GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery _
>>> ("select * from Win32_OperatingSystem where Primary=true")
>>>
>>> for each OpSys in OpSysSet
>>> OpSys.Reboot()
>>> next
>>>
>>>
>>>
>>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>>> news:%23cOJpgZzJHA.6004@TK2MSFTNGP02.phx.gbl...
>>>> First, is the computer currently a domain member, not a workgroup
>>>> member? If so - and only if so - you first need to use the
>>>> UnjoinDomainOrWorkgroup the way you have it.
>>>>
>>>> The second step is to use JoinDomainOrWorkgroup, like this:
>>>>
>>>> objComputer.JoinDomainOrWorkgroup("workgroup")
>>>>
>>>>
>>>> you have the necessary privileges, don't bother with arguments
>>>>
>>>> "Joey" <j***@joey.com> wrote in message
>>>> news:eIAv$aQzJHA.1372@TK2MSFTNGP05.phx.gbl...
>>>>> how do I modify the below to join a workgroup name "workgroup" instead
>>>>> of the domain name?
>>>>>
>>>>> Set objNetwork = CreateObject("WScript.Network")
>>>>> strComputer = objNetwork.ComputerName
>>>>> Set objComputer =
>>>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer
>>>>> & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
>>>>> strDomain = objComputer.Domain
>>>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>>>>
>>>
>>>
>
>
Author
11 May 2009 5:59 PM
Joey
it says cannot use parenthesus when calling a Sub

Show quoteHide quote
"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
wrote in message news:%23e5cSHb0JHA.3408@TK2MSFTNGP04.phx.gbl...
> Instead of using Win32_OperatingSystem's Reboot() method, you're probably
> better off using its Win32Shutdown; this allows you forced shutdown
> (trying to kill all processes isn't going to work - it will kill your own
> script as well, and some processes won't be touched).
>
> You want to specify restart + forcing, which is a value of 6 if you check
> the online documentation for the method:
>
> http://msdn.microsoft.com/en-us/library/aa394058%28VS.85%29.aspx
>
> so use it like this:
>    OpSys.Win32Shutdown( 6, 0)
>
>
> "Joey" <j***@joey.com> wrote in message
> news:#A$bDIQ0JHA.2300@TK2MSFTNGP06.phx.gbl...
>> yes after joining the domain, there isa process that keeps hanging and
>> waiting for a "end now". I want to be able to kill that process and then
>> reboot
>>
>> "Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
>> wrote in message news:upPFJc0zJHA.5032@TK2MSFTNGP05.phx.gbl...
>>> Since you're using the Reboot() method, that will happen automatically.
>>> Are you running into problems with making this work in a specific
>>> situation?
>>>
>>> "Joey" <j***@joey.com> wrote in message
>>> news:euFxo9nzJHA.1492@TK2MSFTNGP04.phx.gbl...
>>>> ok
>>>>
>>>> how do I add a line that will kill all processes ?
>>>>
>>>> Set objNetwork = CreateObject("WScript.Network")
>>>> strComputer = objNetwork.ComputerName
>>>> Set objComputer =
>>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer
>>>> & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
>>>> 'strDomain = objComputer.Domain
>>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>>> intReturn1 = objComputer.JoinDomainOrWorkgroup("workgroup")
>>>>
>>>>
>>>> Set OpSysSet =
>>>> GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery _
>>>> ("select * from Win32_OperatingSystem where Primary=true")
>>>>
>>>> for each OpSys in OpSysSet
>>>> OpSys.Reboot()
>>>> next
>>>>
>>>>
>>>>
>>>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>>>> news:%23cOJpgZzJHA.6004@TK2MSFTNGP02.phx.gbl...
>>>>> First, is the computer currently a domain member, not a workgroup
>>>>> member? If so - and only if so - you first need to use the
>>>>> UnjoinDomainOrWorkgroup the way you have it.
>>>>>
>>>>> The second step is to use JoinDomainOrWorkgroup, like this:
>>>>>
>>>>> objComputer.JoinDomainOrWorkgroup("workgroup")
>>>>>
>>>>>
>>>>> you have the necessary privileges, don't bother with arguments
>>>>>
>>>>> "Joey" <j***@joey.com> wrote in message
>>>>> news:eIAv$aQzJHA.1372@TK2MSFTNGP05.phx.gbl...
>>>>>> how do I modify the below to join a workgroup name "workgroup"
>>>>>> instead of the domain name?
>>>>>>
>>>>>> Set objNetwork = CreateObject("WScript.Network")
>>>>>> strComputer = objNetwork.ComputerName
>>>>>> Set objComputer =
>>>>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
>>>>>> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer
>>>>>> & "'")
>>>>>> strDomain = objComputer.Domain
>>>>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>>>>>
>>>>
>>>>
>>
>>
Author
11 May 2009 8:20 PM
Alex K. Angelopoulos
Ah, you're not capturing the return value. Do so, and that fixes the
problem:

intRtn = OpSys.Win32Shutdown( 6, 0)

alternatively, if you don't want to check the return value, just don't use
the parentheses. VBScript has weird syntax requirements:

OpSys.Win32Shutdown 6, 0

Show quoteHide quote
"Joey" <j***@joey.com> wrote in message
news:OvCTsIm0JHA.2656@TK2MSFTNGP05.phx.gbl...
> it says cannot use parenthesus when calling a Sub
>
> "Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
> wrote in message news:%23e5cSHb0JHA.3408@TK2MSFTNGP04.phx.gbl...
>> Instead of using Win32_OperatingSystem's Reboot() method, you're probably
>> better off using its Win32Shutdown; this allows you forced shutdown
>> (trying to kill all processes isn't going to work - it will kill your own
>> script as well, and some processes won't be touched).
>>
>> You want to specify restart + forcing, which is a value of 6 if you check
>> the online documentation for the method:
>>
>> http://msdn.microsoft.com/en-us/library/aa394058%28VS.85%29.aspx
>>
>> so use it like this:
>>    OpSys.Win32Shutdown( 6, 0)
>>
>>
>> "Joey" <j***@joey.com> wrote in message
>> news:#A$bDIQ0JHA.2300@TK2MSFTNGP06.phx.gbl...
>>> yes after joining the domain, there isa process that keeps hanging and
>>> waiting for a "end now". I want to be able to kill that process and then
>>> reboot
>>>
>>> "Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
>>> wrote in message news:upPFJc0zJHA.5032@TK2MSFTNGP05.phx.gbl...
>>>> Since you're using the Reboot() method, that will happen automatically.
>>>> Are you running into problems with making this work in a specific
>>>> situation?
>>>>
>>>> "Joey" <j***@joey.com> wrote in message
>>>> news:euFxo9nzJHA.1492@TK2MSFTNGP04.phx.gbl...
>>>>> ok
>>>>>
>>>>> how do I add a line that will kill all processes ?
>>>>>
>>>>> Set objNetwork = CreateObject("WScript.Network")
>>>>> strComputer = objNetwork.ComputerName
>>>>> Set objComputer =
>>>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer
>>>>> & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
>>>>> 'strDomain = objComputer.Domain
>>>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>>>> intReturn1 = objComputer.JoinDomainOrWorkgroup("workgroup")
>>>>>
>>>>>
>>>>> Set OpSysSet =
>>>>> GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery _
>>>>> ("select * from Win32_OperatingSystem where Primary=true")
>>>>>
>>>>> for each OpSys in OpSysSet
>>>>> OpSys.Reboot()
>>>>> next
>>>>>
>>>>>
>>>>>
>>>>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>>>>> news:%23cOJpgZzJHA.6004@TK2MSFTNGP02.phx.gbl...
>>>>>> First, is the computer currently a domain member, not a workgroup
>>>>>> member? If so - and only if so - you first need to use the
>>>>>> UnjoinDomainOrWorkgroup the way you have it.
>>>>>>
>>>>>> The second step is to use JoinDomainOrWorkgroup, like this:
>>>>>>
>>>>>> objComputer.JoinDomainOrWorkgroup("workgroup")
>>>>>>
>>>>>>
>>>>>> you have the necessary privileges, don't bother with arguments
>>>>>>
>>>>>> "Joey" <j***@joey.com> wrote in message
>>>>>> news:eIAv$aQzJHA.1372@TK2MSFTNGP05.phx.gbl...
>>>>>>> how do I modify the below to join a workgroup name "workgroup"
>>>>>>> instead of the domain name?
>>>>>>>
>>>>>>> Set objNetwork = CreateObject("WScript.Network")
>>>>>>> strComputer = objNetwork.ComputerName
>>>>>>> Set objComputer =
>>>>>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
>>>>>>> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" &
>>>>>>> strComputer & "'")
>>>>>>> strDomain = objComputer.Domain
>>>>>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Author
12 May 2009 6:05 PM
Joey
thank you very much
Show quoteHide quote
"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
wrote in message news:ujAi9Xn0JHA.1900@TK2MSFTNGP04.phx.gbl...
> Ah, you're not capturing the return value. Do so, and that fixes the
> problem:
>
> intRtn = OpSys.Win32Shutdown( 6, 0)
>
> alternatively, if you don't want to check the return value, just don't use
> the parentheses. VBScript has weird syntax requirements:
>
> OpSys.Win32Shutdown 6, 0
>
> "Joey" <j***@joey.com> wrote in message
> news:OvCTsIm0JHA.2656@TK2MSFTNGP05.phx.gbl...
>> it says cannot use parenthesus when calling a Sub
>>
>> "Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
>> wrote in message news:%23e5cSHb0JHA.3408@TK2MSFTNGP04.phx.gbl...
>>> Instead of using Win32_OperatingSystem's Reboot() method, you're
>>> probably better off using its Win32Shutdown; this allows you forced
>>> shutdown (trying to kill all processes isn't going to work - it will
>>> kill your own script as well, and some processes won't be touched).
>>>
>>> You want to specify restart + forcing, which is a value of 6 if you
>>> check the online documentation for the method:
>>>
>>> http://msdn.microsoft.com/en-us/library/aa394058%28VS.85%29.aspx
>>>
>>> so use it like this:
>>>    OpSys.Win32Shutdown( 6, 0)
>>>
>>>
>>> "Joey" <j***@joey.com> wrote in message
>>> news:#A$bDIQ0JHA.2300@TK2MSFTNGP06.phx.gbl...
>>>> yes after joining the domain, there isa process that keeps hanging and
>>>> waiting for a "end now". I want to be able to kill that process and
>>>> then reboot
>>>>
>>>> "Alex K. Angelopoulos" <alex(dot) k(dot
>>>> again)angelopoulos(at)gmail.com> wrote in message
>>>> news:upPFJc0zJHA.5032@TK2MSFTNGP05.phx.gbl...
>>>>> Since you're using the Reboot() method, that will happen
>>>>> automatically. Are you running into problems with making this work in
>>>>> a specific situation?
>>>>>
>>>>> "Joey" <j***@joey.com> wrote in message
>>>>> news:euFxo9nzJHA.1492@TK2MSFTNGP04.phx.gbl...
>>>>>> ok
>>>>>>
>>>>>> how do I add a line that will kill all processes ?
>>>>>>
>>>>>> Set objNetwork = CreateObject("WScript.Network")
>>>>>> strComputer = objNetwork.ComputerName
>>>>>> Set objComputer =
>>>>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
>>>>>> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer
>>>>>> & "'")
>>>>>> 'strDomain = objComputer.Domain
>>>>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>>>>> intReturn1 = objComputer.JoinDomainOrWorkgroup("workgroup")
>>>>>>
>>>>>>
>>>>>> Set OpSysSet =
>>>>>> GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery _
>>>>>> ("select * from Win32_OperatingSystem where Primary=true")
>>>>>>
>>>>>> for each OpSys in OpSysSet
>>>>>> OpSys.Reboot()
>>>>>> next
>>>>>>
>>>>>>
>>>>>>
>>>>>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>>>>>> news:%23cOJpgZzJHA.6004@TK2MSFTNGP02.phx.gbl...
>>>>>>> First, is the computer currently a domain member, not a workgroup
>>>>>>> member? If so - and only if so - you first need to use the
>>>>>>> UnjoinDomainOrWorkgroup the way you have it.
>>>>>>>
>>>>>>> The second step is to use JoinDomainOrWorkgroup, like this:
>>>>>>>
>>>>>>> objComputer.JoinDomainOrWorkgroup("workgroup")
>>>>>>>
>>>>>>>
>>>>>>> you have the necessary privileges, don't bother with arguments
>>>>>>>
>>>>>>> "Joey" <j***@joey.com> wrote in message
>>>>>>> news:eIAv$aQzJHA.1372@TK2MSFTNGP05.phx.gbl...
>>>>>>>> how do I modify the below to join a workgroup name "workgroup"
>>>>>>>> instead of the domain name?
>>>>>>>>
>>>>>>>> Set objNetwork = CreateObject("WScript.Network")
>>>>>>>> strComputer = objNetwork.ComputerName
>>>>>>>> Set objComputer =
>>>>>>>> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
>>>>>>>> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" &
>>>>>>>> strComputer & "'")
>>>>>>>> strDomain = objComputer.Domain
>>>>>>>> intReturn = objComputer.UnjoinDomainOrWorkgroup (NULL,NULL,0)
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>