VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,737 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I need to create a program to restart 3 remote, non AD joined servers. Using VS2019 and I added the LoginForm to the project. Now I am lost. Can anybody point me in the right direction to collect a username and password and then pass that to a restart command to restart these 3 servers? I have this written in PowerShell, however when I turn it into an executable, it no longer works in Citrix, so I am having to knock off the VB.NET rust and try it this way.
Thanks
Scott
Hi,
you can use following console demo:
Option Infer On
Option Strict On
Imports System.Management
Imports System.Management.Instrumentation
Module Module1
Sub main()
Dim sComp As String = "192.168.0.96"
Dim opts As New ConnectionOptions
With opts
.Username = InputBox("Please enter your user name:")
.Password = InputBox("Please enter your password:")
End With
Dim ms As New ManagementScope("\\" & sComp & "\root\cimv2", opts)
ms.Connect()
Dim oq As New ObjectQuery("Select * From Win32_OperatingSystem")
Dim mos As New ManagementObjectSearcher(ms, oq)
Dim col = mos.Get
For Each mo As ManagementObject In mos.Get
Dim ss As String() = {""}
mo.InvokeMethod("Reboot", ss)
Next
Console.ReadLine()
End Sub
End Module