XtremeMaC Posted January 31, 2005 Share Posted January 31, 2005 hi thereis there such utility that will check if a service is running via command prompt?so it'll check the memory for running services, also is there a program to check for running apps via command prompt? well i've actually found some programs but how can i modify them so that they return 0's 1's or true false etc..1 tool from sysinternals psservice.thanks Link to comment Share on other sites More sharing options...
MCT Posted January 31, 2005 Share Posted January 31, 2005 i think someone posted a commandfile on how 2 check the status of a service via command file, maybe have a look with the search?i THINK it maybe was jdoehttp://www.msfn.org/board/index.php?showtopic=34628&hl=start Link to comment Share on other sites More sharing options...
oftentired Posted January 31, 2005 Share Posted January 31, 2005 From the WinXP command line:SC (the non-MS explanation)SC (the MS explanation) Link to comment Share on other sites More sharing options...
XtremeMaC Posted January 31, 2005 Author Share Posted January 31, 2005 thanks both!how about a program to check in an executable is running? Link to comment Share on other sites More sharing options...
Yzöwl Posted January 31, 2005 Share Posted January 31, 2005 You could check the state with TASKLIST and close it with TASKKILL, or probably use TASKKILL on its own. For a clue a look at /FI (Filter_Name) Status, Operators eq, ne and Values RUNNING|NOT RESPONDING Link to comment Share on other sites More sharing options...
XtremeMaC Posted January 31, 2005 Author Share Posted January 31, 2005 well okay better yet lemme explain what i'm trying to do i've perfect disk installed, it has 2 services and 1 exe to get it running.services:pdenginepdschedexecutable:perfectdisk.exestarting the app:check if pdsched is running, if its running do nothing, else start the servicecheck if pdengine is running, if its running do nothing, else start the servicecheck if both services are running if so then start the executable if its not already running.stopping the app:net stop pdengine /ynet stop pdsched taskkill /f /im perfectdisk.exenow the stopping part is easy but i've problems on the starting part, can anyone help? thanks Link to comment Share on other sites More sharing options...
jaclaz Posted January 31, 2005 Share Posted January 31, 2005 You mean these:http://www.jsiinc.com/SUBB/tip0700/rh0770.htmhttp://www.robvanderwoude.com/processes.htmlhttp://www.teamcti.com/pview/prcview.htmjaclaz Link to comment Share on other sites More sharing options...
Yzöwl Posted January 31, 2005 Share Posted January 31, 2005 @ XtremeMaCI'm only playing with batch files, but how about trying something like this!You will need to put the correct path in the SET Proc line, and quotes will only be needed if there are spaces in the path@ECHO OFFSETLOCALSET Proc="%ProgramFiles%\subdirectory\perfectdisk.exe"SET Svcs=pdengine pdschedFOR %%a IN (%Svcs%) DO SC query %%a | FIND /i "RUNNING"IF ERRORLEVEL 1 SC start %%aTASKLIST | FIND /i "perfectdisk.exe"IF ERRORLEVEL 1 START "" %Proc%ENDLOCALGOTO :EOF Link to comment Share on other sites More sharing options...
oftentired Posted January 31, 2005 Share Posted January 31, 2005 thanks both!how about a program to check in an executable is running? There is a little tiny program called PV.EXE that comes in the ZIP file for PrcView 3.7.3.1 which will do exactly what you are trying to do. It returns error levels for use in batch files. In the ZIP file the two files you would be interested in are PV.EXE and PV.TXT. The text file is very complete. Link to comment Share on other sites More sharing options...
XtremeMaC Posted February 3, 2005 Author Share Posted February 3, 2005 thanks all!!!just saw this, dunno why i sometimes don't get reply notification via emailanyways thanks for all the usefull stuff. i'm so bad at this dos stuff. Link to comment Share on other sites More sharing options...
Yzöwl Posted February 3, 2005 Share Posted February 3, 2005 @XtremeMaCAs I said that I was playing with batches, could you let me know if it works please. I may use a similar idea for something else, and would be grateful of the feedback. Link to comment Share on other sites More sharing options...
rakeshmathur Posted January 28, 2009 Share Posted January 28, 2009 Maybe no one is looking for this anymore...but thid did not work when I used on Windows 2003. I am having trouble executing this line: IF ERRORLEVEL 1 SC start %%aCan anyone help?Thanks! RM Link to comment Share on other sites More sharing options...
rakeshmathur Posted January 28, 2009 Share Posted January 28, 2009 Okay, I was able to get this to work, this is the final script I used: FOR %%a IN (%Svcs%) DO (SC query %%a | FIND /i "RUNNING"IF ERRORLEVEL 1 SC start %%a)the parentheses did the trick. ThanksRM Link to comment Share on other sites More sharing options...
ccyborg Posted November 28, 2011 Share Posted November 28, 2011 a script that try to stop tomcat service and retry if still running until retry limit is not reached@echo offSET CATALINA_HOME=C:\SAP BusinessObjects\Tomcat6SET /A RETRYMAX=10SET /A NBRETRY=1SET /A WAITBEFORERETRY=3:STOPecho.stopping...CALL "%CATALINA_HOME%\bin\shutdown.bat"sc query "BOEXI40Tomcat" | find /i "RUNNING"IF ERRORLEVEL 1 GOTO END:RETRYIF [%NBRETRY%]==[%RETRYMAX%] GOTO END echo. echo.------------------ echo. %NBRETRY% echo. wait %WAITBEFORERETRY%sec echo.------------------ echo.SET /A NBRETRY+=1Timeout /T %WAITBEFORERETRY% /NOBREAKGOTO STOP:ENDecho.ENDSET RETRYMAX=SET NBRETRY= Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now