1.

Solve : How to check to see if a service is running on multiple computers?

Answer»

Hey all;

I'd like to write a batch file (not good with powershell or the wmic command) that reads a TEXT file for computer names, then runs the sc.exe command against each one then builds a list (csv) file that looks like "computername, running or computername, stopped". I greatly appreciate any help.

cfowlerDumping the output from this command to a file is easy with adding >> to the END of the command followed by the file you want the output to go to. But if you want this data in a structure that will be clean to work with in CSV format in excel etc, you will have to clean it up with another routine to refine it.

so if you add >>Output.csv to the end of the instruction it will redirect the output which is normally to the user display to be written appended to the csv file. So after it is run on say 5 systems, you would have a list of info written to this csv. But it will be just as it is presented on a display but DUMPED as raw text to a csv file that has no DELIMITER to import clean to a spreadsheet.

If you just want to GENERATE a report to see which computers have services active or inactive you can just append the redirected output to a text File such as adding >>Output.txt to the end of the line that has the instruction to check for service running.Already capable of that - run the command from the command prompt manually against every machine - no thank you - over 1500 machines. Not looking for the appending command, looking for the way to employ a loop, if anyone can share that knowledge it would be greatly appreciated.Code: [Select]For /f "delims=" %%A in ('type "FILENAME_HERE") do
SC ....... >>output.txt
)
%%A is the name of the computer.

where FILENAME_HERE is formatted thus:
Code: [Select]Computer1
Computer2
Computer3
Computer4
Computer5
Computer6
Computer7
Quote from: cfowler on September 06, 2013, 09:49:56 AM

I'd like to write a batch file (not good with powershell or the wmic command) that reads a text file for computer names, then runs the sc.exe command against each one then builds a list (csv) file that looks like "computername, running or computername, stopped". I greatly appreciate any help.

"computername, running or computername, stopped"

What information do you want? I don't think you have specified the task properly.



Quote from: foxidrive on September 16, 2013, 07:20:05 PM
"computername, running or computername, stopped"

What information do you want? I don't think you have specified the task properly.

The end result of what I'm after would be a file called endresult.csv (for example), which would look something like this:

computername1,running
computername2,running
computername3,stopped

Does that explain it a bit better?Have you mentioned anywhere which service you are testing?


Discussion

No Comment Found