G
Guest
Hi There,
Very much a newbie to VB and Macros.
I have a script which is linked as a macro to a button on a worksheet. The
script is used to get info about a PC and it's logged on user. Running the VB
script out of Excel functions normally and I'm able to see the displayed info
in a WSH window. However when I run it in the Excel workbook the inital
message box is opened but the resulting info is not displayed.
This is the script
***********************************
Dim s, System, Item, RemotePC
Sub Button5_Click()
RemotePC = InputBox("Enter in computer name to query", "")
On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
Set System = GetObject("winmgmts:\\" & RemotePC &
"\root\cimv2").instancesOf("Win32_ComputerSystem")
For Each Item In System
s = "Computer Info" & vbCrLf
s = s & "***********************" & vbCrLf
s = s & "Name: " & Item.Name & vbCrLf
s = s & "Status: " & Item.Status & vbCrLf
s = s & "Type: " & Item.SystemType & vbCrLf
s = s & "Mfg: " & Item.Manufacturer & vbCrLf
s = s & "Model: " & Item.Model & vbCrLf
s = s & "RAM: ~" & Item.TotalPhysicalMemory \ 1024000 & " MB" & vbCrLf
s = s & "User: " & Item.UserName
If Item.Status = "OK" Then
Item.Status = "Enabled"
Else
Item.Status = "Disabled"
End If
If Item.Status = "Disabled" Then
WScript.Echo "No connection available"
Else
WScript.Echo s
End If
Next
End Sub
*******************************
Any guru help would be appreciated.
Very much a newbie to VB and Macros.
I have a script which is linked as a macro to a button on a worksheet. The
script is used to get info about a PC and it's logged on user. Running the VB
script out of Excel functions normally and I'm able to see the displayed info
in a WSH window. However when I run it in the Excel workbook the inital
message box is opened but the resulting info is not displayed.
This is the script
***********************************
Dim s, System, Item, RemotePC
Sub Button5_Click()
RemotePC = InputBox("Enter in computer name to query", "")
On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
Set System = GetObject("winmgmts:\\" & RemotePC &
"\root\cimv2").instancesOf("Win32_ComputerSystem")
For Each Item In System
s = "Computer Info" & vbCrLf
s = s & "***********************" & vbCrLf
s = s & "Name: " & Item.Name & vbCrLf
s = s & "Status: " & Item.Status & vbCrLf
s = s & "Type: " & Item.SystemType & vbCrLf
s = s & "Mfg: " & Item.Manufacturer & vbCrLf
s = s & "Model: " & Item.Model & vbCrLf
s = s & "RAM: ~" & Item.TotalPhysicalMemory \ 1024000 & " MB" & vbCrLf
s = s & "User: " & Item.UserName
If Item.Status = "OK" Then
Item.Status = "Enabled"
Else
Item.Status = "Disabled"
End If
If Item.Status = "Disabled" Then
WScript.Echo "No connection available"
Else
WScript.Echo s
End If
Next
End Sub
*******************************
Any guru help would be appreciated.