MultiSelect from DatagridView to function question

  • Thread starter Thread starter Jason Spatz
  • Start date Start date
J

Jason Spatz

Guest
Good Morning,

I am working on a small project, and I am basically a newb to this platform, but I have made a program that stores a bunch of computer names and descriptions in a sql table. and lets a specific user reboot the pc when it stops behaving properly. I grab some data like this on specfic button clicks based on the type of computer it is.

LoadGrid("select ServerName, Description from CaseTrackingBoards where Application = 'CareView';")

and right now I select one row and do this

Private Sub btnRebootCTB_Click(sender As Object, e As EventArgs) Handles btnRebootCTB.Click
RebootMachine(DGViewFirstNet.CurrentCell.FormattedValue)
End Sub

which does

Private Sub RebootMachine(RebootServer As String)
'MsgBox("You have chosen to reboot " & RebootServer)
If MessageBox.Show("Are you sure you wish to reboot " & RebootServer & "?", "Confirm reboot",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) = System.Windows.Forms.DialogResult.Yes Then
Using RebootProc As New Process
With RebootProc.StartInfo
.CreateNoWindow = False
.FileName = "shutdown.exe"
.Arguments = String.Format("-r -m \\{0} -c ""PC unresponsive Jake rebooted"" -t 1", RebootServer)
.UseShellExecute = False
.WindowStyle = ProcessWindowStyle.Hidden
.RedirectStandardOutput = True
.RedirectStandardInput = True
End With
RebootProc.Start()
End Using
End If

End Sub

This all works fine .. but we want a way to just reboot all 5 or 6 with one button click. I am assuming I would have to work with the dgview.selectedrows, and I would think I would have to pop all the "ServerName" values into an array or something and feed that into a new sub and loop through those ServerNames and pretty much do as above. But I can't find the syntax to do this properly for VB. This doesn't feel like it should be hard.. but I am at a loss and I am failing BING today.. :)


Thank you for any assistance!

Jay

Continue reading...
 
Back
Top