joing a workgroup

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kbodily@metalast_noSpam.com

    #1

    joing a workgroup

    How does one go about joining a workgroup using vb.net code?

  • ECathell

    #2
    Re: joing a workgroup

    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.CreateO bject("WScript. Shell")
    strFile = "ComputerList.t xt"
    objShell.Run "cmd /c net view /DOMAIN:WORKGROU P >" & strFile, 0 , TRUE
    Wscript.echo "WARNING" & vbCrLF & "Take this time to edit the
    computerlist.tx t" & vbCrLF & "Press OK, once complete"
    Dim objValue, OldPCName, NewPCName, oWshShell, test, command
    Set ObjFSO = CreateObject("s cripting.FileSy stemObject")
    Set objComputerlist = objFSO.OpenText File("ComputerL ist.txt", ForReading)
    Do until objComputerList .AtEndofStream
    strComputer = RTrim(Left(objC omputerlist.rea dline, 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



    Comment

    • kbodily@metalast_noSpam.com

      #3
      Re: joing a workgroup

      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:[color=blue]
      > 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.CreateO bject("WScript. Shell")
      > strFile = "ComputerList.t xt"
      > objShell.Run "cmd /c net view /DOMAIN:WORKGROU P >" & strFile, 0 , TRUE
      > Wscript.echo "WARNING" & vbCrLF & "Take this time to edit the
      > computerlist.tx t" & vbCrLF & "Press OK, once complete"
      > Dim objValue, OldPCName, NewPCName, oWshShell, test, command
      > Set ObjFSO = CreateObject("s cripting.FileSy stemObject")
      > Set objComputerlist = objFSO.OpenText File("ComputerL ist.txt", ForReading)
      > Do until objComputerList .AtEndofStream
      > strComputer = RTrim(Left(objC omputerlist.rea dline, 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[/color]

      Comment

      • ECathell

        #4
        Re: joing a workgroup

        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@metala st_noSpam.com" <kbodily@metala st.com> wrote in message
        news:1122654901 .125870.273840@ z14g2000cwz.goo glegroups.com.. .[color=blue]
        > 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:[color=green]
        >> 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.CreateO bject("WScript. Shell")
        >> strFile = "ComputerList.t xt"
        >> objShell.Run "cmd /c net view /DOMAIN:WORKGROU P >" & strFile, 0 , TRUE
        >> Wscript.echo "WARNING" & vbCrLF & "Take this time to edit the
        >> computerlist.tx t" & vbCrLF & "Press OK, once complete"
        >> Dim objValue, OldPCName, NewPCName, oWshShell, test, command
        >> Set ObjFSO = CreateObject("s cripting.FileSy stemObject")
        >> Set objComputerlist = objFSO.OpenText File("ComputerL ist.txt", ForReading)
        >> Do until objComputerList .AtEndofStream
        >> strComputer = RTrim(Left(objC omputerlist.rea dline, 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[/color]
        >[/color]


        Comment

        Working...