Page 1 of 1 1
Topic Options
#68395 - 2002-07-16 05:44 PM Capturing Net Start errors
Anonymous
Unregistered


Hi All,
I've got a piece of software that is comprised of several services on a Windows NT 4 server. For general maintenance purposes, we have to stop and restart its services nightly. We have automated this process in a script using the net start command.

The problem is that every once in a while, a service will fail to start - returning an error 2140. Unfortunately, no event log message is made as a result - just the error message.

How do I get Kixtart to "catch" an error message resulting from the net start command?

Thanks in advance for any assistance [Smile]

Top
#68396 - 2002-07-16 05:55 PM Re: Capturing Net Start errors
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
there are two ways to catch an error.
easiest way with net use is to use kix internal error method.

try it out with something similar to:

shell "net start alloverthehouse"
? "error @error was expected"

works great for me.
cheers,

[ 16 July 2002, 18:02: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#68397 - 2002-07-16 05:56 PM Re: Capturing Net Start errors
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Don,

What you can do is something like:

SHELL "%COMSPEC% /C net start > c:\log.txt"

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#68398 - 2002-07-16 06:14 PM Re: Capturing Net Start errors
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
what about this?
code:
$COMPUTER="server"

$getobj=GetObject("winmgmts:{impersonationLevel=impersonate}!//$COMPUTER")
$errmsg=$getobj.ExecQuery("Select * From Win32_NTLogEvent Where EventIdentifier='2140'")

For each $event in $errmsg
$message=$event.message
$ec =$event.EventIdentifier
$time =$event.TimeGenerated
$year =substr("$time",1,4) $hour=substr("$time",9,2)
$month =substr("$time",5,2) $min =substr("$time",11,2)
$day =substr("$time",7,2) $sec =substr("$time",13,2)

? "$ec $month/$day/$year $hour:$min:$sec"
? $Message
?
next

I use this to pull ntbackup messages
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#68399 - 2002-07-16 06:20 PM Re: Capturing Net Start errors
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Rad,

This would be good if he has Kixtart 4.x, but did not see what version he is running?

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#68400 - 2002-07-16 07:12 PM Re: Capturing Net Start errors
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
btw.. if you need to record a command's error channel you need to specify channel 2

SHELL "%COMSPEC% /C net start 2> c:\log.txt"
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#68401 - 2002-07-17 12:44 AM Re: Capturing Net Start errors
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
i got the best score boys [Big Grin]
_________________________
!

download KiXnet

Top
#68402 - 2002-07-17 02:23 AM Re: Capturing Net Start errors
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear Lonkero,

Isn't it returning to the wrong topic?
We think that the golf guys want to know your current score.
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.067 seconds in which 0.034 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org