Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Reboot remote server from ASP.NET (VB.NET) using WMI

Reply
Thread Tools

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

 
 
Ken Tucker
Guest
Posts: n/a
 
      07-05-2003
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" <(E-Mail Removed)> 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
>
> -------



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OT: How to reboot remote PC via VPN/Remote Desktop? (PeteCresswell) Wireless Networking 9 02-08-2013 02:18 PM
WMI remote call in python script to create process on remote windowscomputer davidj411 Python 7 10-08-2009 08:58 AM
Reboot, reboot, reboot Lawrence D'Oliveiro NZ Computing 12 03-07-2009 11:35 PM
To reboot the PIX or not reboot - that is the question Darren Green Cisco 1 03-14-2006 10:59 PM
Trying To Query Remote Machine Using WMI & ASP.NET Fails With "Invalid Class" Winterminute ASP .Net 0 12-04-2003 07:35 PM



Advertisments