Computer Hope

Microsoft => Microsoft Windows => Windows XP => Topic started by: Sogent on July 02, 2012, 02:52:16 PM

Title: Tasklist used in Batch file causes ERROR: RCP service is unavailable.
Post by: Sogent on July 02, 2012, 02:52:16 PM
The batch file is trying to set the errorlevel and check it to branch to the proper command line to start a new command.

@ECHO OFF
FOR /F %%F in (%1) do(
ECHO %%F
Testlist /s %%F U administrator P dapassword | findstr StartRT.exe
echo %ERRORLEVEL%
IF %ERRORLEVEL%==1(
ECHO "SERVICE IS RUNNING" ) ELSE (
ECHO "SERVICE IS NOT RUNNING")
)


This is run from the command line by typing test.bat consoles.lst where the latter has three LAN  console addressed included.

The output echoes the console address then list the ERROR listed above and then list the errorlevel that does not change.  In all trials it listthe last value set.
Title: Re: Tasklist used in Batch file causes ERROR: RCP service is unavailable.
Post by: Salmon Trout on July 02, 2012, 03:50:17 PM
1. Your title says "Tasklist used in batch file" but the code you posted does not use Tasklist; it does mention something called Testlist though.

2. Did you mean "The RCP Server is unavailable"?

3. Check the status and startup type for the RPC and RPC locator services on the server that gets the error. Additional Services that may result in "The RPC Server is Unavailable" errors are the TCP/IP NetBIOS helper service, Distributed File System service and Remote Registry service. These services should both be set to automatic and started. The Kerberos Key Distribution Center (KDC) should be Started and Automatic on Windows 2000 and Windows 2003 DCs. It should not be started and set to Disabled in all other cases.

4. You are not seeing up to date values of errorlevel because inside a FOR or other parenthetical structure if you SET a variable or try to read a changing system variable implicitly (like errorlevel, date, time etc) you need to use delayed expansion to get the value to expand properly inside that structure.
Title: Re: Tasklist used in Batch file causes ERROR: RCP service is unavailable.
Post by: Sogent on July 03, 2012, 09:26:10 AM
 ;D
The testlist statement is a typo.  It is in my code tasklist.  I believe I have found the reason for  the  RCP Error.  I put " " around the object of FINDSTR and the error has stopped.  However, errorlevel is not updating.

I will try to understand the delayed expansion you refer to.

Thanks for your help
Title: Re: Tasklist used in Batch file causes ERROR: RCP service is unavailable.
Post by: Salmon Trout on July 03, 2012, 10:22:02 AM

I will try to understand the delayed expansion you refer to.


Google "delayed expansion batch" or search this forum.

Good page here

http://www.robvanderwoude.com/variableexpansion.php