Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Net Start return codes

1,971 views
Skip to first unread message

Pegasus (MVP)

unread,
Feb 23, 2008, 4:51:54 AM2/23/08
to

"Gareth Cornish" <Gareth...@discussions.microsoft.com> wrote in message
news:FFBF4719-CB51-4379...@microsoft.com...
> Good morning,
>
> I'm writing a VBS script for Windows XP and Server 2003. The script uses
> the
> Run method to call a "Net Start" command, to start a service. This command
> returns an integer error code, but I can't find anywhere to tell me what
> these return codes mean.
>
> I know that 0 indicates success, and I suspect that 2 indicates that the
> service was already running, but I can't find anything to confirm this.
>
> Thanks
> --
> Gareth Cornish
> CornishWeb
> http://www.cornishweb.com

With most commands, an ErrorLevel greater than 0 indicates a
failure of some sort. It's the same with net.exe. With "net start"
2 could mean that the service was already running, or that there
is no such service, and probably a few other error conditions too.


Gareth Cornish

unread,
Feb 23, 2008, 5:18:01 AM2/23/08
to
Thanks. I understand the theory, but it's the details I need. Somewhere there
must be documentation for net.exe that says, "error code X occurs when ...".
I just don't know where to find it - the best I can find just tells me that
the command returns an integer.

Paul Randall

unread,
Feb 23, 2008, 10:55:39 AM2/23/08
to
This is just a wild guess, but perhaps the error code X can just be
plugged into a 'net helpmsg x' command.

-Paul Randall

"Gareth Cornish" <Gareth...@discussions.microsoft.com> wrote in

message news:1A365C9B-5CA1-47A0...@microsoft.com...

Tom Lavedas

unread,
Feb 23, 2008, 11:06:59 AM2/23/08
to
On Feb 23, 5:18 am, Gareth Cornish

<GarethCorn...@discussions.microsoft.com> wrote:
> Thanks. I understand the theory, but it's the details I need. Somewhere there
> must be documentation for net.exe that says, "error code X occurs when ...".
> I just don't know where to find it - the best I can find just tells me that
> the command returns an integer.
>
> "Pegasus (MVP)" wrote:
>
> > "Gareth Cornish" <GarethCorn...@discussions.microsoft.com> wrote in message

> >news:FFBF4719-CB51-4379...@microsoft.com...
> > > Good morning,
>
> > > I'm writing a VBS script for Windows XP and Server 2003. The script uses
> > > the
> > > Run method to call a "Net Start" command, to start a service. This command
> > > returns an integer error code, but I can't find anywhere to tell me what
> > > these return codes mean.
>
> > > I know that 0 indicates success, and I suspect that 2 indicates that the
> > > service was already running, but I can't find anything to confirm this.
>
> > > Thanks
> > > --
> > > Gareth Cornish
> > > CornishWeb
> > >http://www.cornishweb.com
>
> > With most commands, an ErrorLevel greater than 0 indicates a
> > failure of some sort. It's the same with net.exe. With "net start"
> > 2 could mean that the service was already running, or that there
> > is no such service, and probably a few other error conditions too.

I found a reference to NET HELPMSG with a google search. I hadn't
known about it before this, though it appears to be a standard command
console utility. When I checked the Windows help for HELPMSG I found
this example ...

NET 2182: The requested service has already been started.

which suggests that an error code of 2 is not related to a started
service error. In fact, when I checked NET HELPMSG 2 it returned ...

The system cannot find the file specified.

I also not that there are MANY, MANY error levels returned from NET,
since its error codes run to four digits (up to 10,000 possibilities,
though there is not an error for every value) so it's just not
practical to provide an exhaustive list. Rather, you'll need to trap
the error and then use NET HELPMG to deliver an explanation.

Tom Lavedas
===========

FUBARinSFO

unread,
Mar 30, 2008, 7:29:58 PM3/30/08
to
Has anyone verfied that there is a one-to-one connection between the
returned errorlevel n and the explanation in HELPMSG? (net helpmsg n)
I've gotten errorlevel=2 in attaching to a network printer, but the
helpmsg is "the system cannot find the file specified". Probably
because it is on a dfferent subnet/workgroup name, but still....

Pegasus (MVP)

unread,
Mar 30, 2008, 7:57:04 PM3/30/08
to

"FUBARinSFO" <file...@gmail.com> wrote in message
news:b1d59ccd-f885-40d1...@e23g2000prf.googlegroups.com...

Best to use the WMI method that D.R. posted in another
branch of this thread. They are very detailed.


0 new messages