I have created a small desktop application which allows users to log a call with our help desk without the need of a browser or email application (since it is locked down)
Within the form code i call a vbs script which collects system information from WMI and then send an email via outlook/cdo (still deciding on email method)
Below is my form code for the send button.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim strName As String
Dim strDept As String
Dim strEmail As String
Dim strExt As String
Dim strDesc As String
Dim strAffect As String
strName = TextBox1.Text
strDept = TextBox2.Text
strEmail = TextBox3.Text
strExt = TextBox4.Text
strDesc = RichTextBox1.Text
strAffect = TextBox5.Text
System.Diagnostics.Process.Start("c:\Temp\Support.vbs")
MessageBox.Show("Thank you!")
Me.Close()
End Sub
End Class
My problem now comes in with the vbscript code. i need to pass the input parameters from the above form (Name, dept, email address, etc) to the VBScript file to use in the email to support, but i have no idea how to do this.
NOTE: I have very basic vbscript and vb experience and google is my friend, i have searched the internet for 2 days to find a solution but to no avail. So naturally this is my last resource
Below is my VBScript file, (support.vbs) which is called by the above form. Its copy and paste code with modification.
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set Arg = WScript.Arguments
Const NUMBER_OF_ROWS = 19
Const NUMBER_OF_COLUMNS = 2
Set objWord = CreateObject("Word.Application")
objWord.Visible = true
Set objDoc = objWord.Documents.Add()
Set objRange = objDoc.Range()
objDoc.Tables.Add objRange, NUMBER_OF_ROWS, NUMBER_OF_COLUMNS
Set objTable = objDoc.Tables(1)
objTable.Cell(1,1).Range.Text = "System Information For: "
objTable.Cell(2,1).Range.Text = "Manufacturer"
objTable.Cell(3,1).Range.Text = "Model"
objTable.Cell(4,1).Range.Text = "Domain Type"
objTable.Cell(5,1).Range.Text = "Total Physical Memory"
objTable.Cell(6,1).Range.Text = "Processor Manufacturer"
objTable.Cell(7,1).Range.Text = "Processor Name"
objTable.Cell(8,1).Range.Text = "Processor Clock Speed"
objTable.Cell(9,1).Range.Text = "Bios Version"
objTable.Cell(10,1).Range.Text = "Serial Number"
objTable.Cell(11,1).Range.Text = "Video Controller"
objTable.Cell(12,1).Range.Text = "CD-ROM Manufacturer"
objTable.Cell(13,1).Range.Text = "CD-ROM Name"
objTable.Cell(14,1).Range.Text = "KeyBoard"
objTable.Cell(15,1).Range.Text = "Primary Drive Size"
objTable.Cell(16,1).Range.Text = "Primary Drive Space Available"
objTable.Cell(17,1).Range.Text = "Service Pack"
objTable.Cell(18,1).Range.Text = "Windows Version"
objTable.Cell(19,1).Range.Text = "IP Address"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem in colItems
objTable.Rows.Add()
objTable.Cell(1, 2).Range.Text = UCase(strComputer)
objTable.Cell(2, 2).Range.Text = objItem.Manufacturer
objTable.Cell(3, 2).Range.Text = objItem.Model
Select Case objItem.DomainRole
Case 0 strComputerRole = "Standalone Workstation"
Case 1 strComputerRole = "Member Workstation"
Case 2 strComputerRole = "Standalone Server"
Case 3 strComputerRole = "Member Server"
Case 4 strComputerRole = "Backup Domain Controller"
Case 5 strComputerRole = "Primary Domain Controller"
End Select
objTable.Cell(4, 2).Range.Text = strComputerRole
objTable.Cell(5, 2).Range.Text = objItem.TotalPhysicalMemory/1048576 & " MB"
Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem in colItems
objTable.Cell(6, 2).Range.Text = objItem.Manufacturer
objTable.Cell(7, 2).Range.Text = objItem.Name
objTable.Cell(8, 2).Range.Text = Round(objItem.MaxClockSpeed) & " MHz"
Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS")
For Each objItem in colItems
objTable.Cell(9, 2).Range.Text = objItem.Version
objTable.Cell(10, 2).Range.Text = objItem.SerialNumber
Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_VideoController")
For Each objItem in colItems
objTable.Cell(11, 2).Range.Text = objItem.Name
Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
For Each objItem in colItems
objTable.Cell(12, 2).Range.Text = objItem.Manufacturer
objTable.Cell(13, 2).Range.Text = objItem.Name
Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_Keyboard")
For Each objItem in colItems
objTable.Cell(14, 2).Range.Text = objItem.Caption
Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where DeviceID = ""C:""")
For Each objItem in colItems
objTable.Cell(15, 2).Range.Text = Round(objItem.Size /1073741824) & " GB"
Next
Set colDisks = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
For Each objDisk in colDisks
objTable.Cell(16, 2).Range.Text = Round(objDisk.Freespace /1073741824) & " GB"
Next
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objTable.Cell(17, 2).Range.Text = objOperatingSystem.ServicePackMajorVersion & "." & objOperatingSystem.ServicePackMinorVersion
Next
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objTable.Cell(18, 2).Range.Text = objOperatingSystem.Caption & " " & objOperatingSystem.Version
Next
Set IPConfigSet = objWMIService.ExecQuery _
("Select IPAddress from Win32_NetworkAdapterConfiguration ")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) _
to UBound(IPConfig.IPAddress)
objTable.Cell(19, 2).Range.Text = IPConfig.IPAddress(i)
Next
End If
Next
objTable.AutoFormat(23)
objDoc.SaveAs("C:\Temp\Sysinfo.doc")
objWord.Quit
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
myAttachments.Add "C:\Temp\Sysinfo.doc"
myItem.Display '-- Optional --
myItem.To = "email address"
myItem.Subject = ""
myItem.Body = "Dear IT Support" & vbCRLF & vbCRLF & "Please assist with the following:" & vbCRLF & vbCRLF & "1. Requester info.: " & strName & vbCRLF & vbCRLF & "2. Brief summary of the issue and error message," & vbCRLF & vbCRLF & "3. Name of system or piece of IT equipment which is not working (eg: screen, keyboard, Internet, etc.)," & vbCRLF & vbCRLF & "3.1 Other issues: " & vbCRLF & vbCRLF & "3.3 Telephone call issues: Telephone number being dialed/received, time issue occurred, Ext. number where issue occurred," & vbCRLF & vbCRLF & "4. Number of users affected by the issue," & vbCRLF & vbCRLF & "5. Step by step replication details(from the login screen until issue occurred)."