Registered: 2000-07-12
Posts: 23
Loc: New York, NY USA
I am in the procces of completing a script that will allow for an Exchange 5.5 site swap and i am stuck at this point.... I need to get the results of the following command
$ExchsrvIS="MSExchangeIS" Shell '%CompSpec% /c net start $ExchsrvIS'
Basically i have tried the @error and @serror, and both supply no usfull information. I need the errors generated from the service start request. Errors i am expecting to see may be 5882, 1011, 1276, and normal ones like service started or service not started.... any advise would be most appreciated. Environment is NT Server 4.0 SP6 with IE 4.0
Thanks in advance, Jeff
_________________________
Jeff Lynch
Network Administrator
Registered: 2000-07-12
Posts: 23
Loc: New York, NY USA
thanks for the prompt reply, error returned is 2 the system cannot find the file specified.... The actual error generated from the net start is... The Microsoft Exchange Information Store could not be started. A service specific error occurred:1276.
not sure how to get this msg to kix
_________________________
Jeff Lynch
Network Administrator
Registered: 2002-08-16
Posts: 624
Loc: London, England
Well now you know that error 2 means "The Microsoft Exchange Information Store could not be started. A service specific error occurred:1276."
so.
code:
$ExchsrvIS="MSExchangeIS" Shell 'net start $ExchsrvIS' If @ERROR = "2" ? "The Microsoft Exchange Information Store could not be started. A service specific error occurred:1276." Endif
Registered: 2000-07-12
Posts: 23
Loc: New York, NY USA
one problem with that is this, if i issue a net stop command i get the same error code. Scenero: MSExchange IS not started net start gives error code 2, actual is ... The Microsoft Exchange Information Store could not be started. A service specific error occurred:1276 net stop gives error code 2, actual is ... The Microsoft Exchange Information Store service is not started.
_________________________
Jeff Lynch
Network Administrator
heh. boys boys. the errors are STANDARD errorcodes. you can't just change the meaning. 2 means what 2 means. if it says 2, it has problem with net. now, if it can't start net, I have to ask is your PATH variable screwed on that machine you try to fire it on.
Registered: 2000-07-12
Posts: 23
Loc: New York, NY USA
sure i can start the service from a command line with a clean DB in the exchange db directory.. will run a few more test on my way home, but most odd, not sure why it would be passing error code 2
_________________________
Jeff Lynch
Network Administrator
not just on commandline but in the dir where the kix is and where the script is. net.exe resides in system32. so if %windir%\system32 is not on your %path%, the error 2 is obvious. otherwise I have to wonder, wonder a lot.
Registered: 2000-07-12
Posts: 23
Loc: New York, NY USA
Okies, now I have made things very simple. And yes my path statement is correct, I thoroughly tested various net commands and all worked from every directory. The script has been changed to test against the alerter service which all NT/XP builds have out of the box. Shell '%ComSpec% /c net stop alerter' "error returned: (" @error ") " @serror
Scenario: Alerter service stopped.
C:\Documents and Settings\lynchj>kix32 d:\kix\svcr1 The Alerter service is stopping. The Alerter service was stopped successfully.
error returned: (0) The operation completed successfully. C:\Documents and Settings\lynchj>kix32 d:\kix\svcr1 The Alerter service is not started.
More help is available by typing NET HELPMSG 3521.
error returned: (2) The system cannot find the file specified. OK now I modified the net stop to be a net start and here are the results.
C:\Documents and Settings\lynchj>kix32 d:\kix\svcr1 The Alerter service is starting. The Alerter service was started successfully.
error returned: (0) The operation completed successfully. C:\Documents and Settings\lynchj>kix32 d:\kix\svcr1 The requested service has already been started.
More help is available by typing NET HELPMSG 2182.
error returned: (2) The system cannot find the file specified.
Okies, goal is to get the actual error txt that is displayed when attempting to start or stop the service, since it returns the same error code when starting or stopping the service. Haven't been stumped with a kix script in a while, and this doesn't logically seem all that hard which is what's making it all the more frustrating Might i be barking up the wrong tree, is there an alternative that can be used to extract the error text?
_________________________
Jeff Lynch
Network Administrator
k, me tested this stuff as don't wanted to say anything not true. and found out that I already did. net seems to NOT have standard errors even thought it should indeed be the standard for that same thing (net helpmsg)
it seems that it always returns 2 as error if service is already in the state you want to set it. this is not in kix only but if you do:
net start workstation
echo %errorlevel%
on commandline, you see that it also returns same errors.
Registered: 2000-07-12
Posts: 23
Loc: New York, NY USA
Thanks for all the assistance folks. This is as far as I have gotten, using excerpts from postings. Was wondering if this was clean or if it could be streamlined more.
Dim $ErrReturn[8] $ExchsrvIS="MSExchangeIS" Shell '%Comspec% /c net stop $ExchsrvIS >%Temp%\status.log 2>%Temp%\err.log' $f=Open(1,"%Temp%\err.log",2) $x=Readline(1) While @error=0 $ErrReturn[$c]=$x $x=Readline(1) $c=$c+1 Loop $f=Close(1) $rc=Substr($ErrReturn[2],Len($ErrReturn[2])-4,4) If $rc="" $rc1=$ErrReturn[0] $rc=Substr($ErrReturn[3],Len($ErrReturn[3])-4,4) Endif Select Case $rc="2182" $ErrCode="The Requested service has already been started." Case $rc="3521" $ErrCode="The "+$ExchsrvIS+" service is not started." Case $rc="5882" $ErrCode="The RIP Key needs to be deleted and ExchangeSA needs to be restarted first." $RC1? Case $rc="1011" $ErrCode="Isinteg needs to e run to bring PRIV to Consistant State." $RC1? Case $rc="1276" $ErrCode="Restored PRIV not meant for current Site, Site needs to be swapped" $RC1? EndSelect ?$ErrCode
Any feedback would be appreciated
_________________________
Jeff Lynch
Network Administrator
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
See the OPEN() example in the KiXtart Manual and use FREEFILEHANDLE() to assign a free filehandle instead of hardcoding it. You also do not check whether the OPEN() is successful. And see the UDF Forum for 'read file' and 'pipe' UDFs.
_________________________
There are two types of vessels, submarines and targets.