Hi,
I am trying to create a batch file that would help me to create the txt file along with the status of the service in a server.
below command provides the status: "running/not running" inside the "servername.txt" file. But I am looking out for a batch file command that would create the txt file with status in its file naming convention. Example: "servername running/notrunning.txt"
NET USE \\servername\IPC$ /USER:Miltonjo_aps password
sc \\servername query "service name" | find "STATE" > servername.txt
Appreciate you guidance..
Regards,
John
Please help me create a batch file which creates txt files
Moderator: DosItHelp
-
- Posts: 1
- Joined: 24 Jan 2015 09:47
Re: Please help me create a batch file which creates txt fil
Code: Select all
@echo off
NET USE \\servername\IPC$ /USER:Miltonjo_aps password
FOR /F "tokens=4" %%G in ('sc \\servername query "service name" ^| find "STATE"') DO set state=%%G
echo %state%>Servername_%state%.txt