Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Tue, 17 Jun 2008 09:08:00 -0700,    group: microsoft.public.win32.programmer.wmi        back       


Rename computer with WMI and .Net problems.   
I am looking to call WMI to do a rename and join workgroup.  The following 
functions compile cleanly but the renale doesn't seem to work:

Function objGetComputerSystem() As ManagementObject
        Dim objectQuery As New ObjectQuery("select * from 
Win32_ComputerSystem")
        Dim searcher As New ManagementObjectSearcher(objectQuery)
        Dim computerSystem As ManagementObject
        Dim computerSystemOut As ManagementObject
        computerSystemOut = Nothing
        For Each computerSystem In searcher.Get()
            computerSystemOut = computerSystem
            Exit For
        Next computerSystem
        Return computerSystemOut
    End Function

    Function renameComputer(ByRef computerSystem As ManagementObject, ByVal 
newName As String) As UInt32
        Dim rc As UInt32

        Dim objArgs(1) As Object
        objArgs(0) = newName
        rc = computerSystem.InvokeMethod("Rename", objArgs)
        Return rc

    End Function

    Function JoinWorkgroup(ByRef computerSystem As ManagementObject, ByVal 
newWorkgroup As String) As UInt32
        Dim rc As UInt32

        Dim objArgs(5) As Object
        objArgs(0) = newWorkgroup
        objArgs(1) = vbNull
        objArgs(2) = vbNull
        objArgs(3) = vbNull
        objArgs(4) = vbNull


        rc = computerSystem.InvokeMethod("JoinDomainOrWorkgroup", objArgs)
        Return rc

    End Function

The objGetComputerSystem  works but the rename silenlly fails.  I havent 
cheched the JoinWorkgroup function yet.  Any Ideas?
date: Tue, 17 Jun 2008 09:08:00 -0700   author:   PzkwVIb

RE: Rename computer with WMI and .Net problems.   
"PzkwVIb" wrote:

> I am looking to call WMI to do a rename and join workgroup.  The following 
> functions compile cleanly but the renale doesn't seem to work:
> 
> Function objGetComputerSystem() As ManagementObject
>         Dim objectQuery As New ObjectQuery("select * from 
> Win32_ComputerSystem")
>         Dim searcher As New ManagementObjectSearcher(objectQuery)
>         Dim computerSystem As ManagementObject
>         Dim computerSystemOut As ManagementObject
>         computerSystemOut = Nothing
>         For Each computerSystem In searcher.Get()
>             computerSystemOut = computerSystem
>             Exit For
>         Next computerSystem
>         Return computerSystemOut
>     End Function
> 
>     Function renameComputer(ByRef computerSystem As ManagementObject, ByVal 
> newName As String) As UInt32
>         Dim rc As UInt32
> 
>         Dim objArgs(1) As Object
>         objArgs(0) = newName
>         rc = computerSystem.InvokeMethod("Rename", objArgs)
>         Return rc
> 
>     End Function
> 
>     Function JoinWorkgroup(ByRef computerSystem As ManagementObject, ByVal 
> newWorkgroup As String) As UInt32
>         Dim rc As UInt32
> 
>         Dim objArgs(5) As Object
>         objArgs(0) = newWorkgroup
>         objArgs(1) = vbNull
>         objArgs(2) = vbNull
>         objArgs(3) = vbNull
>         objArgs(4) = vbNull
> 
> 
>         rc = computerSystem.InvokeMethod("JoinDomainOrWorkgroup", objArgs)
>         Return rc
> 
>     End Function
> 
> The objGetComputerSystem  works but the rename silenlly fails.  I havent 
> cheched the JoinWorkgroup function yet.  Any Ideas?


You need to restart the computer in order to see the changed name. Have you 
tried that?

-- 
urkec
date: Tue, 17 Jun 2008 11:27:00 -0700   author:   urkec

RE: Rename computer with WMI and .Net problems.   
Yes, I have tried rebooting.  No joy.

"urkec" wrote:

> "PzkwVIb" wrote:
> 
> > I am looking to call WMI to do a rename and join workgroup.  The following 
> > functions compile cleanly but the renale doesn't seem to work:
> > 
> > Function objGetComputerSystem() As ManagementObject
> >         Dim objectQuery As New ObjectQuery("select * from 
> > Win32_ComputerSystem")
> >         Dim searcher As New ManagementObjectSearcher(objectQuery)
> >         Dim computerSystem As ManagementObject
> >         Dim computerSystemOut As ManagementObject
> >         computerSystemOut = Nothing
> >         For Each computerSystem In searcher.Get()
> >             computerSystemOut = computerSystem
> >             Exit For
> >         Next computerSystem
> >         Return computerSystemOut
> >     End Function
> > 
> >     Function renameComputer(ByRef computerSystem As ManagementObject, ByVal 
> > newName As String) As UInt32
> >         Dim rc As UInt32
> > 
> >         Dim objArgs(1) As Object
> >         objArgs(0) = newName
> >         rc = computerSystem.InvokeMethod("Rename", objArgs)
> >         Return rc
> > 
> >     End Function
> > 
> >     Function JoinWorkgroup(ByRef computerSystem As ManagementObject, ByVal 
> > newWorkgroup As String) As UInt32
> >         Dim rc As UInt32
> > 
> >         Dim objArgs(5) As Object
> >         objArgs(0) = newWorkgroup
> >         objArgs(1) = vbNull
> >         objArgs(2) = vbNull
> >         objArgs(3) = vbNull
> >         objArgs(4) = vbNull
> > 
> > 
> >         rc = computerSystem.InvokeMethod("JoinDomainOrWorkgroup", objArgs)
> >         Return rc
> > 
> >     End Function
> > 
> > The objGetComputerSystem  works but the rename silenlly fails.  I havent 
> > cheched the JoinWorkgroup function yet.  Any Ideas?
> 
> 
> You need to restart the computer in order to see the changed name. Have you 
> tried that?
> 
> -- 
> urkec
date: Tue, 17 Jun 2008 11:55:00 -0700   author:   PzkwVIb

RE: Rename computer with WMI and .Net problems.   
I just found out if I remove teh computer from the domain first the rename 
works.  

Thanks

"urkec" wrote:

> "PzkwVIb" wrote:
> 
> > I am looking to call WMI to do a rename and join workgroup.  The following 
> > functions compile cleanly but the renale doesn't seem to work:
> > 
> > Function objGetComputerSystem() As ManagementObject
> >         Dim objectQuery As New ObjectQuery("select * from 
> > Win32_ComputerSystem")
> >         Dim searcher As New ManagementObjectSearcher(objectQuery)
> >         Dim computerSystem As ManagementObject
> >         Dim computerSystemOut As ManagementObject
> >         computerSystemOut = Nothing
> >         For Each computerSystem In searcher.Get()
> >             computerSystemOut = computerSystem
> >             Exit For
> >         Next computerSystem
> >         Return computerSystemOut
> >     End Function
> > 
> >     Function renameComputer(ByRef computerSystem As ManagementObject, ByVal 
> > newName As String) As UInt32
> >         Dim rc As UInt32
> > 
> >         Dim objArgs(1) As Object
> >         objArgs(0) = newName
> >         rc = computerSystem.InvokeMethod("Rename", objArgs)
> >         Return rc
> > 
> >     End Function
> > 
> >     Function JoinWorkgroup(ByRef computerSystem As ManagementObject, ByVal 
> > newWorkgroup As String) As UInt32
> >         Dim rc As UInt32
> > 
> >         Dim objArgs(5) As Object
> >         objArgs(0) = newWorkgroup
> >         objArgs(1) = vbNull
> >         objArgs(2) = vbNull
> >         objArgs(3) = vbNull
> >         objArgs(4) = vbNull
> > 
> > 
> >         rc = computerSystem.InvokeMethod("JoinDomainOrWorkgroup", objArgs)
> >         Return rc
> > 
> >     End Function
> > 
> > The objGetComputerSystem  works but the rename silenlly fails.  I havent 
> > cheched the JoinWorkgroup function yet.  Any Ideas?
> 
> 
> You need to restart the computer in order to see the changed name. Have you 
> tried that?
> 
> -- 
> urkec
date: Tue, 17 Jun 2008 12:25:01 -0700   author:   PzkwVIb

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us