By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,712 Members | 1,319 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,712 IT Pros & Developers. It's quick & easy.

joing a workgroup

P: n/a
How does one go about joining a workgroup using vb.net code?

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
here is a VBScript way...I imagine you can convert it to vb.net. It gathers
the names of all the computers in a workgroup, allows you to edit the list
then loops through and joins them to the new workgroup. Each computer must
have the same admin account and password for this to work.

dim objShell
const Minimize_Window = 2
const ForReading = 1
Set objShell = WScript.CreateObject("WScript.Shell")
strFile = "ComputerList.txt"
objShell.Run "cmd /c net view /DOMAIN:WORKGROUP >" & strFile, 0 , TRUE
Wscript.echo "WARNING" & vbCrLF & "Take this time to edit the
computerlist.txt" & vbCrLF & "Press OK, once complete"
Dim objValue, OldPCName, NewPCName, oWshShell, test, command
Set ObjFSO = CreateObject("scripting.FileSystemObject")
Set objComputerlist = objFSO.OpenTextFile("ComputerList.txt", ForReading)
Do until objComputerList.AtEndofStream
strComputer = RTrim(Left(objComputerlist.readline, 17))
'wscript.echo "net use \\" & strComputer & "\ipc$ /user:username password"
objShell.Run "net use \\" & strComputer & "\ipc$ /user:username password",
1, TRUE
'wscript.echo "netdom.exe MEMBER \\" & strComputer & " /joinworkgroup
newworkgroup"
objShell.Run "netdom.exe MEMBER \\" & strComputer & " /joinworkgroup
newworkgroup", 1, TRUE
Loop
Eric

Nov 21 '05 #2

P: n/a
Thanks Eric,
You seem to be using netdom to join the workgroup. Unfortunatley, I
cannot guarantee it is installed on the machine the code will run on.
Any other ways?
kevin
ECathell wrote:
here is a VBScript way...I imagine you can convert it to vb.net. It gathers
the names of all the computers in a workgroup, allows you to edit the list
then loops through and joins them to the new workgroup. Each computer must
have the same admin account and password for this to work.

dim objShell
const Minimize_Window = 2
const ForReading = 1
Set objShell = WScript.CreateObject("WScript.Shell")
strFile = "ComputerList.txt"
objShell.Run "cmd /c net view /DOMAIN:WORKGROUP >" & strFile, 0 , TRUE
Wscript.echo "WARNING" & vbCrLF & "Take this time to edit the
computerlist.txt" & vbCrLF & "Press OK, once complete"
Dim objValue, OldPCName, NewPCName, oWshShell, test, command
Set ObjFSO = CreateObject("scripting.FileSystemObject")
Set objComputerlist = objFSO.OpenTextFile("ComputerList.txt", ForReading)
Do until objComputerList.AtEndofStream
strComputer = RTrim(Left(objComputerlist.readline, 17))
'wscript.echo "net use \\" & strComputer & "\ipc$ /user:username password"
objShell.Run "net use \\" & strComputer & "\ipc$ /user:username password",
1, TRUE
'wscript.echo "netdom.exe MEMBER \\" & strComputer & " /joinworkgroup
newworkgroup"
objShell.Run "netdom.exe MEMBER \\" & strComputer & " /joinworkgroup
newworkgroup", 1, TRUE
Loop
Eric


Nov 21 '05 #3

P: n/a
I just have it in the folder I run the script from. I think if you use .NET
you will still need to use those same libraries...
--
--Eric Cathell, MCSA
"kbodily@metalast_noSpam.com" <kb*****@metalast.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanks Eric,
You seem to be using netdom to join the workgroup. Unfortunatley, I
cannot guarantee it is installed on the machine the code will run on.
Any other ways?
kevin
ECathell wrote:
here is a VBScript way...I imagine you can convert it to vb.net. It
gathers
the names of all the computers in a workgroup, allows you to edit the
list
then loops through and joins them to the new workgroup. Each computer
must
have the same admin account and password for this to work.

dim objShell
const Minimize_Window = 2
const ForReading = 1
Set objShell = WScript.CreateObject("WScript.Shell")
strFile = "ComputerList.txt"
objShell.Run "cmd /c net view /DOMAIN:WORKGROUP >" & strFile, 0 , TRUE
Wscript.echo "WARNING" & vbCrLF & "Take this time to edit the
computerlist.txt" & vbCrLF & "Press OK, once complete"
Dim objValue, OldPCName, NewPCName, oWshShell, test, command
Set ObjFSO = CreateObject("scripting.FileSystemObject")
Set objComputerlist = objFSO.OpenTextFile("ComputerList.txt", ForReading)
Do until objComputerList.AtEndofStream
strComputer = RTrim(Left(objComputerlist.readline, 17))
'wscript.echo "net use \\" & strComputer & "\ipc$ /user:username
password"
objShell.Run "net use \\" & strComputer & "\ipc$ /user:username
password",
1, TRUE
'wscript.echo "netdom.exe MEMBER \\" & strComputer & " /joinworkgroup
newworkgroup"
objShell.Run "netdom.exe MEMBER \\" & strComputer & " /joinworkgroup
newworkgroup", 1, TRUE
Loop
Eric

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.