i'm writing a little utility for my job, i need to change the actual machine name into serial number of the machine, i already found how to get serial number but i have no idea how to set the machine name and every solution i have tried haven't worked, someone have some suggestions?
Dim q As New SelectQuery("Win32_bios")
Dim search As New ManagementObjectSearcher(q)
Dim info As New ManagementObject
Try
For Each info In search.Get
Call MessageBox.Show("Serial Number: " & info("serialnumber").ToString +
vbCrLf + "Machine Name : " + Environment.MachineName)
Next
Return 1
Catch err As ManagementException
Call MessageBox.Show("Error: " & err.Message)
Return -99
End Try
I found a solution
Dim p As Process = New Process()
Dim pi As ProcessStartInfo = New ProcessStartInfo()
pi.Verb = "Runas"
pi.WindowStyle = ProcessWindowStyle.Hidden
pi.Arguments = "/K WMIC computersystem where caption='" + Environment.MachineName + "' rename Prova"
pi.FileName = "cmd.exe"
pi.UseShellExecute = True
pi.CreateNoWindow = True
Process.Start(pi)
It's just an utility for me but there is a way if i don't want ask the permission to run the process?