(1) Run : Windows CMD(Command Prompt)
(2) Type below command
GET CPU DETAILS
wmic cpu get deviceid, numberofcores,numberoflogicalprocessors
GET MODEL OF REMOTE COMPUTER
* Local PC
wmic computersystem get model, manufacturer
* Network PC
wmic /node:%ipaddress% computersystem get model, manufacturer
GET BIOS SERIAL NO.
* Local PC
wmic bios get serialnumber
* Network PC
wmic /node:%ipaddress%bios get serialnumber
FIND INSTALLED PROGRAM
* Local PC
wmic product get vendor, name
* Network PC
wmic /node:%ipaddress% product get vendor, name
INSTALL REMOTELY
wmic /node:%ipaddress% product call install true,"","rootdirectory\pathtoyour\file.msi"
UNSTALL SOFTWARE ON REMOTEPC's
wmic /node:%ipaddress% product where name=%softwaretobeunstall%" call uninstall
Free Download Sample VB.Net Apps and its Data Source Code
Thursday, June 30, 2016
ADD, UPDATE, DELETE FROM Database VB.NET
Imports System.Data
Imports System.Data.SqlClient
ADD
'--------------------------------------------------------------------------------
Dim xcounter As Integer = 0
Try
myconn = New SqlConnection(My.Settings.testsettings)
myconn.Open()
mycmd = New SqlCommand("insert into test1 (fname,mname,lname) values ('" & TextBox1.Text & "' , '" & TextBox2.Text & "' , '" & TextBox3.Text & "')", myconn)
xcounter = mycmd.ExecuteNonQuery
MessageBox.Show("(" & xcounter & ") affected")
myconn.Close()
mycmd.Dispose()
Catch ex As Exception
myconn.Close()
mycmd.Dispose()
MessageBox.Show(ex.Message)
End Try
'--------------------------------------------------------------------------------
EDIT
'--------------------------------------------------------------------------------
Dim xcounter As Integer = 0
Try
myconn = New SqlConnection(My.Settings.testsettings)
If myconn.State = System.Data.ConnectionState.Closed Then
myconn.Open()
End If
mycmd = New SqlCommand("update test1 set fname='" & TextBox4.Text & "' , mname='" & TextBox5.Text & "' , lname='" & TextBox6.Text & "' where id ='" & idd & "'", myconn)
xcounter = mycmd.ExecuteNonQuery
MessageBox.Show("(" & xcounter & ") affected")
myconn.Close()
mycmd.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message, "asdf")
myconn.Close()
mycmd.Dispose()
End Try
'--------------------------------------------------------------------------------
DELETE
'--------------------------------------------------------------------------------
If MessageBox.Show("Are your sure to delete '" & DataGridView1.SelectedRows(0).Cells(0).Value & "'", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes Then
Dim xcounter As Integer = 0
Try
myconn = New SqlConnection(My.Settings.testsettings)
myconn.Open()
mycmd = New SqlCommand("delete from test1 where id='" & idd & "'", myconn)
xcounter = mycmd.ExecuteNonQuery
MessageBox.Show("(" & xcounter & ") affected")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
myconn.Close()
mycmd.Dispose()
gview()
End If
'--------------------------------------------------------------------------------
Imports System.Data.SqlClient
ADD
'--------------------------------------------------------------------------------
Dim xcounter As Integer = 0
Try
myconn = New SqlConnection(My.Settings.testsettings)
myconn.Open()
mycmd = New SqlCommand("insert into test1 (fname,mname,lname) values ('" & TextBox1.Text & "' , '" & TextBox2.Text & "' , '" & TextBox3.Text & "')", myconn)
xcounter = mycmd.ExecuteNonQuery
MessageBox.Show("(" & xcounter & ") affected")
myconn.Close()
mycmd.Dispose()
Catch ex As Exception
myconn.Close()
mycmd.Dispose()
MessageBox.Show(ex.Message)
End Try
'--------------------------------------------------------------------------------
EDIT
'--------------------------------------------------------------------------------
Dim xcounter As Integer = 0
Try
myconn = New SqlConnection(My.Settings.testsettings)
If myconn.State = System.Data.ConnectionState.Closed Then
myconn.Open()
End If
mycmd = New SqlCommand("update test1 set fname='" & TextBox4.Text & "' , mname='" & TextBox5.Text & "' , lname='" & TextBox6.Text & "' where id ='" & idd & "'", myconn)
xcounter = mycmd.ExecuteNonQuery
MessageBox.Show("(" & xcounter & ") affected")
myconn.Close()
mycmd.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message, "asdf")
myconn.Close()
mycmd.Dispose()
End Try
'--------------------------------------------------------------------------------
DELETE
'--------------------------------------------------------------------------------
If MessageBox.Show("Are your sure to delete '" & DataGridView1.SelectedRows(0).Cells(0).Value & "'", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes Then
Dim xcounter As Integer = 0
Try
myconn = New SqlConnection(My.Settings.testsettings)
myconn.Open()
mycmd = New SqlCommand("delete from test1 where id='" & idd & "'", myconn)
xcounter = mycmd.ExecuteNonQuery
MessageBox.Show("(" & xcounter & ") affected")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
myconn.Close()
mycmd.Dispose()
gview()
End If
'--------------------------------------------------------------------------------
Sunday, June 26, 2016
Read and Save .TXT file - VB.Net
READ .TXT File
'TextBox7.Text - browsed file to load
'TextBox8.Text - display
'------------------------------------------
Try
Dim objreader As New System.IO.StreamReader(TextBox7.Text)
TextBox8.Text = objreader.ReadToEnd
objreader.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'------------------------------------------
SAVE .TXT File
'TextBox7.Text - browsed file to save as
'TextBox8.Text - display
'------------------------------------------
Try
Dim objwrite As New System.IO.StreamWriter(TextBox7.Text)
objwrite.Write(TextBox8.Text)
objwrite.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'------------------------------------------
Friday, June 24, 2016
Restart Windows Services VB.NET
Restart Windows Services VB.NET
Imports System
Imports System.ServiceProcess
Imports System.IO
Imports System.Threading
'------------------------------------------------------------------------------------
Public Class Form1
Dim x As Integer
'------------------------------------------------------------------------------------
Public Shared Function RestartService(ByVal ServiceName As String) As Boolean
Dim mySC As ServiceProcess.ServiceController
mySC = New ServiceProcess.ServiceController(ServiceName)
If mySC.Status.ToString = "Running" Then
Form1.Label1.Text = "STOPPING SERVICES"
mySC.Stop()
Form1.x = 5
Form1.Timer1.Enabled = True
End If
If mySC.Status.ToString = "Stopped" Then
Form1.Label1.Text = "RUNNING SERVICES"
mySC.Start()
Form1.x = 5
Form1.Timer2.Enabled = True
End If
End Function
'------------------------------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = ""
Label2.Text = ""
RestartService(TextBox1.Text)
End Sub
'------------------------------------------------------------------------------------
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim mySC As ServiceProcess.ServiceController
mySC = New ServiceProcess.ServiceController(TextBox1.Text)
If x = 0 Then
If mySC.Status.ToString = "Stopped" Then
Label1.Text = "RERUNNING SERVICES"
Label2.Text = ""
mySC.Start()
Timer1.Enabled = False
x = 5
Timer2.Enabled = True
Else
x = 5
Timer1.Enabled = True
End If
Else
x = x - 1
Label2.Text = "TRYING. . . ." & " " & x
TextBox2.Text = (mySC.Status.ToString())
End If
End Sub
'------------------------------------------------------------------------------------
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim mySC As ServiceProcess.ServiceController
mySC = New ServiceProcess.ServiceController(TextBox1.Text)
If x = 0 Then
If mySC.Status.ToString = "Running" Then
Label1.Text = "DONE"
Label2.Text = ""
Timer2.Enabled = False
Else
x = 5
Timer2.Enabled = True
End If
Else
x = x - 1
Label2.Text = "TRYING. . . ." & " " & x
TextBox2.Text = (mySC.Status.ToString())
End If
End Sub
'------------------------------------------------------------------------------------
End Class
Imports System
Imports System.ServiceProcess
Imports System.IO
Imports System.Threading
'------------------------------------------------------------------------------------
Public Class Form1
Dim x As Integer
'------------------------------------------------------------------------------------
Public Shared Function RestartService(ByVal ServiceName As String) As Boolean
Dim mySC As ServiceProcess.ServiceController
mySC = New ServiceProcess.ServiceController(ServiceName)
If mySC.Status.ToString = "Running" Then
Form1.Label1.Text = "STOPPING SERVICES"
mySC.Stop()
Form1.x = 5
Form1.Timer1.Enabled = True
End If
If mySC.Status.ToString = "Stopped" Then
Form1.Label1.Text = "RUNNING SERVICES"
mySC.Start()
Form1.x = 5
Form1.Timer2.Enabled = True
End If
End Function
'------------------------------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = ""
Label2.Text = ""
RestartService(TextBox1.Text)
End Sub
'------------------------------------------------------------------------------------
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim mySC As ServiceProcess.ServiceController
mySC = New ServiceProcess.ServiceController(TextBox1.Text)
If x = 0 Then
If mySC.Status.ToString = "Stopped" Then
Label1.Text = "RERUNNING SERVICES"
Label2.Text = ""
mySC.Start()
Timer1.Enabled = False
x = 5
Timer2.Enabled = True
Else
x = 5
Timer1.Enabled = True
End If
Else
x = x - 1
Label2.Text = "TRYING. . . ." & " " & x
TextBox2.Text = (mySC.Status.ToString())
End If
End Sub
'------------------------------------------------------------------------------------
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim mySC As ServiceProcess.ServiceController
mySC = New ServiceProcess.ServiceController(TextBox1.Text)
If x = 0 Then
If mySC.Status.ToString = "Running" Then
Label1.Text = "DONE"
Label2.Text = ""
Timer2.Enabled = False
Else
x = 5
Timer2.Enabled = True
End If
Else
x = x - 1
Label2.Text = "TRYING. . . ." & " " & x
TextBox2.Text = (mySC.Status.ToString())
End If
End Sub
'------------------------------------------------------------------------------------
End Class
Subscribe to:
Posts (Atom)