Re: Reboot remote server from ASP.NET (VB.NET) using WMI

Discussion in 'ASP .Net' started by Ken Tucker, Jul 5, 2003.

  1. Ken Tucker

    Ken Tucker Guest

    Mickey,

    There is a free class here to help you reboot the system.
    http://www.mentalis.org/soft/class.qpx?id=7

    Ken
    ----------------
    "Mickey Blue" <> wrote in message
    news:Xns93AF7E5DCD921MBlue@206.127.4.10...
    > Hello All
    >
    > I'm attempting to use WMI to reboot a remote server from an ASP.NET page,
    > however I'm clearly missing some key piece of knowledge. Can anybody
    > please tell me what I'm doing wrong?
    >
    > Thanks in advance.
    >
    > Here's the relevant code:
    >
    > -------
    >
    > Private Sub btnBoot_Click(ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) Handles btnBoot.Click
    > 'Get name of computer to reboot
    > '(List on the Web page named lstMemberList contains the names)
    > Dim strComputer As String = lstMemberList.SelectedItem.Text
    > 'WMI objects
    > Dim objManScope As System.Management.ManagementScope
    > Dim objQuery As System.Management.ObjectQuery
    > Dim objSearcher As ManagementObjectSearcher
    > Dim colQueryCollection As ManagementObjectCollection
    > Dim outParams As ManagementBaseObject
    > Dim colInstances As Collection
    > Dim objInstance
    > Dim strWQLQuery As String
    > Dim intResult As Integer
    > 'Build WQL string
    > strWQLQuery = "SELECT * FROM Win32_OperatingSystem " & _
    > "WHERE Primary = ""True"""
    > 'Connect to WMI on remote computer
    > objManScope = New System.Management.ManagementScope("\\" & _
    > strComputer & "\root\cimv2")
    > objQuery = New System.Management.ObjectQuery(strWQLQuery)
    > objSearcher = New ManagementObjectSearcher(objManScope, objQuery)
    > colQueryCollection = objSearcher.Get
    > 'Reboot remote computer
    > For Each objInstance In colQueryCollection
    > 'intResult = objInstance.Win32Shutdown(6) '6 = ForcedReboot
    > outParams = objInstance.InvokeMethod("Reboot", "", "")
    > Next
    > End Sub
    >
    > -------
     
    Ken Tucker, Jul 5, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Winterminute
    Replies:
    0
    Views:
    3,103
    Winterminute
    Dec 4, 2003
  2. rooster575
    Replies:
    2
    Views:
    407
    Trevor Benedict R
    Jun 18, 2004
  3. davidj411
    Replies:
    7
    Views:
    3,288
    Tim Golden
    Oct 8, 2009
  4. Lain
    Replies:
    0
    Views:
    172
  5. Mark
    Replies:
    2
    Views:
    316
Loading...

Share This Page