WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Network

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Move Computer to a Workgroup from a Domain Member


A sample script for moving a computer to a workgroup, you must be a local admin to run and reboot for the change to take effect.
#DefineFunction JoinWG(workgroup)
dll=StrCat(DirWindows(1),"netapi32.dll")
ret2=1
ret=DllCall(dll, long:"NetUnjoinDomain", lpnull, lpnull,lpnull,long:0)
If ret==0 Then
q=(StrLen(workgroup)*2) +2
bb=BinaryAlloc(q)
BinaryPokeStr(bb,0,workgroup)
BinaryConvert(bb,0,3,0,0)
ret2=DllCall(dll, long:"NetJoinDomain", lpnull,lpbinary:bb,lpnull,lpnull,lpnull,long:0) ;
BinaryFree(bb)
EndIf
If ret2==0 Then
Return(1)
Else
Return(0)
EndIf
#EndFunction



If JoinWG("Workgroup")==@TRUE Then
Message ("Results","Join Workgroup suceeded")
Else
Message ("Results","Join Workgroup Failed")
EndIf

Article ID:   W17254
File Created: 2007:07:03:14:29:02
Last Updated: 2007:07:03:14:29:02