Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim wmi As ManagementClass
Dim inParams, outParams As ManagementBaseObject
Dim obj As ManagementObject
Dim Result As String
wmi = New ManagementClass("\\" & strComputer & "\root\cimv2:Win32_OperatingSystem")
For Each obj In wmi.GetInstances()
' Get an input parameters object for this method
inParams = obj.GetMethodParameters("Win32Shutdown")
' fill 'em in
inParams("Flags") = actionOption + 4
inParams("Reserved") = 0
' do it!
outParams = obj.InvokeMethod("Win32Shutdown", inParams, Nothing)
Result = Convert.ToInt32(outParams("returnValue"))
Next
End Sub
As you see i this is what i have setup so far as far as the backgroundworker goes.... this is just a segment of code but i didnt feel the rest was needed. ANYWAYS, when i found out about the backgroundworker and that it might solve another problem ive been having unrelatedly, I copied a Sub that i had into the backgroundwoker. The Sub i copied had 2 other agruements passed through it, a String and an Int (in the code they are strComputer, and actionOption.
I want this in the background mainly because when i go to shut down all the computers at night it will work a while, freeze the whole program while doing this and then unknowingly freeze and stop randomly through it.
Any ideas, or help will be much appreciated, thanks!

New Topic/Question
Reply




MultiQuote




|