• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

Query remote PC Service State - Results in GUI

I have a batch file that I am using to verify the service state of a specific service on numerous computers.  The output is displayed within a command window.

How can this same idea be put into a standalone executable where I can enter the names of the computers that I wish to query on the status of any service?  I'd like to have the output displayed within the window of a GUI too (instead of relying on the command windows).

Any takers out there?
0
tru504187211
Asked:
tru504187211
  • 3
1 Solution
 
TommySzalapskiCommented:
What methods do you have available to use? Do you have Visual Studio so you can use Windows forms or something?

You could also embed the code in an Excel document and use either userforms or the spreadsheet for input and output.

vbScript would be another option since any computer running Windows will support it and you can use commands very similar to the ones you already know from the batch script.
0
 
tru504187211Author Commented:
I do not have VS...if need be, I'd be open to web files (like PHP, or .NET).

Does this help??
0
 
TommySzalapskiCommented:
Web files don't do well interfacing with the filesystem. I recommend VBScript.

For starters, try this vbscript. Save the following code into a text file and save it as a .vbs file (like test.vbs)

Then just double click it. I set it so that hitting cancel deletes the last computer name entered.

Option Explicit

Dim result
Dim prompt
Dim count, i
Dim computers()
Dim shell
Dim output

Set shell = WScript.CreateObject("WScript.Shell")

prompt = ""
result = ""
output = ""
count = 0

While result <> "Done"

  prompt = ""
  For i = 1 To count
    prompt = prompt & computers(i) & chr(13) & chr(10)
  Next

  result = InputBox(prompt, "Enter Computers", "Done")
  If result <> "" And result <> "Done" Then
    ReDim Preserve computers(count + 1)
    count = count + 1
    computers(count) = result
  End If
  If result = "" and count > 0 Then
    ReDim Preserve computers(count - 1)
    count = count - 1
  End If
Wend

For i = 1 To count

  shell.Run "%comspec% /c echo Put any DOS commands here", 0, True

Next

output = output & "Line 1" & chr(13) & chr(10)
output = output & "Line 2" & chr(13) & chr(10)
output = output & "Line 3" & chr(13) & chr(10)

MsgBox output

Open in new window

0
 
TommySzalapskiCommented:
You can probably convert most of your .bat file code directly into VBScript, but you should post them as new questions in the VBScript zone (I'm not the best at DOS -> VBScript translation).
0
 
wls3Commented:
This could be done very easily in Powershell as well.  The popup is quite a bit easier in VBScript, but, Powershell is quite a bit more flexible.  It's also a lot wordier (meaning you tend to have to type more to accomplish the same thing).  Powershell is Visual Studio light in script form in my mind.  

How do you specify the server list?  Is it in the script or manually entered somehow?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now