add / modify / delete service 
Author Message
 add / modify / delete service

hey all,
    how do i add a new service and configure it to run automatically, give
admin previliges, etc using windows scripting? i need the services to be
automated, in the sense to automatically add a service on click of a script
file? how do i do this? please enlighten me on this. thank you.

rgds,
muthu
---
Experience is a hard teacher because she gives the test first, the lesson
afterwards.



Sun, 26 Sep 2004 12:48:50 GMT  
 add / modify / delete service
You want to look at the documentation on WMI for this.

Here's a basic example of creating a service with WMI, drawn partially from a
post by Venkat Reddy to the  WSH group last summer:

Dim bRet
Set oSvc = GetObject("winmgmts:"_
&"{impersonationLevel=impersonate}!Win32_Service")
bRet = oSvc.Create("MySvc","MySvc", _
 & "c:\Service.exe", 16, 1,"Manual", True)
If (bRet<>0) Then wscript.echo "Failed: " & bRet

You've asked several questions in there; I would suggest you go ahead and take a
look through the archives at Google to get a background feel for what you need,
since these are topics that have been addressed several times.


Quote:
> hey all,
>     how do i add a new service and configure it to run automatically, give
> admin previliges, etc using windows scripting? i need the services to be
> automated, in the sense to automatically add a service on click of a script
> file? how do i do this? please enlighten me on this. thank you.

> rgds,
> muthu
> ---
> Experience is a hard teacher because she gives the test first, the lesson
> afterwards.



Sun, 26 Sep 2004 14:32:02 GMT  
 add / modify / delete service
alex, thanx man, btw, can u send me the complete doc sent by venkat? i guess
it wud be useful...

rgds,
muthu

--
---
Experience is a hard teacher because she gives the test first, the lesson
afterwards.


Quote:
> You want to look at the documentation on WMI for this.

> Here's a basic example of creating a service with WMI, drawn partially
from a
> post by Venkat Reddy to the  WSH group last summer:

> Dim bRet
> Set oSvc = GetObject("winmgmts:"_
> &"{impersonationLevel=impersonate}!Win32_Service")
> bRet = oSvc.Create("MySvc","MySvc", _
>  & "c:\Service.exe", 16, 1,"Manual", True)
> If (bRet<>0) Then wscript.echo "Failed: " & bRet

> You've asked several questions in there; I would suggest you go ahead and
take a
> look through the archives at Google to get a background feel for what you
need,
> since these are topics that have been addressed several times.



> > hey all,
> >     how do i add a new service and configure it to run automatically,
give
> > admin previliges, etc using windows scripting? i need the services to be
> > automated, in the sense to automatically add a service on click of a
script
> > file? how do i do this? please enlighten me on this. thank you.

> > rgds,
> > muthu
> > ---
> > Experience is a hard teacher because she gives the test first, the
lesson
> > afterwards.



Sun, 26 Sep 2004 16:42:34 GMT  
 add / modify / delete service

Quote:

> alex, thanx man, btw, can u send me the complete doc sent by venkat? i guess
> it wud be useful...

Why not use a Google newsgroup search for this:

http://groups.google.com/groups?as_ugroup=microsoft.public.scripting....

Direct link to the thread "win32_service Create fails with ret code 21":

http://groups.google.com/groups?hl=en&th=dc1e4ee34d6b6e0d&rnum=1

--
torgeir



Sun, 26 Sep 2004 16:54:39 GMT  
 add / modify / delete service
And it will be no more helpful...


Quote:

> > alex, thanx man, btw, can u send me the complete doc sent by venkat? i guess
> > it wud be useful...

> Why not use a Google newsgroup search for this:

http://groups.google.com/groups?as_ugroup=microsoft.public.scripting....
hors=Venkat%20Reddy&as_scoring=d
Quote:

> Direct link to the thread "win32_service Create fails with ret code 21":

> http://groups.google.com/groups?hl=en&th=dc1e4ee34d6b6e0d&rnum=1

> --
> torgeir



Sun, 26 Sep 2004 18:24:14 GMT  
 add / modify / delete service
hey i can add the service now, thanx to everyone, but i again have a
problem, the service that i am trying to start depends on RPC (rpcss). when
i give the name in the dependencies array, it does not act any different.
the dependency is not listed. i try it in the foll manner

bRet =
oSvc.Create("mTalk","mTalk","c:\winnt\system32\mtalk.exe",16,1,"Automatic",F
alse,"domain\admin","password",NULL,NULL,["rpcss"])

please enlighten me on this. i am still stuck :((

muthu

--
---
Experience is a hard teacher because she gives the test first, the lesson
afterwards.


Quote:
> And it will be no more helpful...




> > > alex, thanx man, btw, can u send me the complete doc sent by venkat? i
guess
> > > it wud be useful...

> > Why not use a Google newsgroup search for this:

http://groups.google.com/groups?as_ugroup=microsoft.public.scripting....
uaut
Quote:
> hors=Venkat%20Reddy&as_scoring=d

> > Direct link to the thread "win32_service Create fails with ret code 21":

> > http://groups.google.com/groups?hl=en&th=dc1e4ee34d6b6e0d&rnum=1

> > --
> > torgeir



Sun, 26 Sep 2004 20:52:11 GMT  
 add / modify / delete service
What are you getting for bRet?

Post that if this doesn't help -

I can't tell  whether anything special needs to be done when creating a service
from script - the SDK only shows programming examples, and says that the
depended services at e a double null terminated string.  I don't know if this is
handled behind the scenes or not, but you might try one of these:

"rpcss"

"rpcss" & vbNull

"rpcss" & vbNull & vbNull


Quote:
> hey i can add the service now, thanx to everyone, but i again have a
> problem, the service that i am trying to start depends on RPC (rpcss). when
> i give the name in the dependencies array, it does not act any different.
> the dependency is not listed. i try it in the foll manner

> bRet =
> oSvc.Create("mTalk","mTalk","c:\winnt\system32\mtalk.exe",16,1,"Automatic",F
> alse,"domain\admin","password",NULL,NULL,["rpcss"])

> please enlighten me on this. i am still stuck :((

> muthu

> --
> ---
> Experience is a hard teacher because she gives the test first, the lesson
> afterwards.


> > And it will be no more helpful...




> > > > alex, thanx man, btw, can u send me the complete doc sent by venkat? i
> guess
> > > > it wud be useful...

> > > Why not use a Google newsgroup search for this:

> http://groups.google.com/groups?as_ugroup=microsoft.public.scripting....
> uaut
> > hors=Venkat%20Reddy&as_scoring=d

> > > Direct link to the thread "win32_service Create fails with ret code 21":

> > > http://groups.google.com/groups?hl=en&th=dc1e4ee34d6b6e0d&rnum=1

> > > --
> > > torgeir



Sun, 26 Sep 2004 22:38:16 GMT  
 add / modify / delete service
hard luck...it did not work...'am still stuck...any helpers out there?

muthu

--
---
Experience is a hard teacher because she gives the test first, the lesson
afterwards.


Quote:
> What are you getting for bRet?

> Post that if this doesn't help -

> I can't tell  whether anything special needs to be done when creating a
service
> from script - the SDK only shows programming examples, and says that the
> depended services at e a double null terminated string.  I don't know if
this is
> handled behind the scenes or not, but you might try one of these:

> "rpcss"

> "rpcss" & vbNull

> "rpcss" & vbNull & vbNull



> > hey i can add the service now, thanx to everyone, but i again have a
> > problem, the service that i am trying to start depends on RPC (rpcss).
when
> > i give the name in the dependencies array, it does not act any
different.
> > the dependency is not listed. i try it in the foll manner

> > bRet =

oSvc.Create("mTalk","mTalk","c:\winnt\system32\mtalk.exe",16,1,"Automatic",F

- Show quoted text -

Quote:
> > alse,"domain\admin","password",NULL,NULL,["rpcss"])

> > please enlighten me on this. i am still stuck :((

> > muthu

> > --
> > ---
> > Experience is a hard teacher because she gives the test first, the
lesson
> > afterwards.

wrote

> > > And it will be no more helpful...




> > > > > alex, thanx man, btw, can u send me the complete doc sent by
venkat? i
> > guess
> > > > > it wud be useful...

> > > > Why not use a Google newsgroup search for this:

http://groups.google.com/groups?as_ugroup=microsoft.public.scripting....

- Show quoted text -

Quote:
> > uaut
> > > hors=Venkat%20Reddy&as_scoring=d

> > > > Direct link to the thread "win32_service Create fails with ret code
21":

> > > > http://groups.google.com/groups?hl=en&th=dc1e4ee34d6b6e0d&rnum=1

> > > > --
> > > > torgeir



Mon, 27 Sep 2004 13:32:00 GMT  
 add / modify / delete service
What are you getting for bRet?


Quote:
> hard luck...it did not work...'am still stuck...any helpers out there?

> muthu

> --
> ---
> Experience is a hard teacher because she gives the test first, the lesson
> afterwards.


> > What are you getting for bRet?

> > Post that if this doesn't help -

> > I can't tell  whether anything special needs to be done when creating a
> service
> > from script - the SDK only shows programming examples, and says that the
> > depended services at e a double null terminated string.  I don't know if
> this is
> > handled behind the scenes or not, but you might try one of these:

> > "rpcss"

> > "rpcss" & vbNull

> > "rpcss" & vbNull & vbNull



> > > hey i can add the service now, thanx to everyone, but i again have a
> > > problem, the service that i am trying to start depends on RPC (rpcss).
> when
> > > i give the name in the dependencies array, it does not act any
> different.
> > > the dependency is not listed. i try it in the foll manner

> > > bRet =

> oSvc.Create("mTalk","mTalk","c:\winnt\system32\mtalk.exe",16,1,"Automatic",F
> > > alse,"domain\admin","password",NULL,NULL,["rpcss"])

> > > please enlighten me on this. i am still stuck :((

> > > muthu

> > > --
> > > ---
> > > Experience is a hard teacher because she gives the test first, the
> lesson
> > > afterwards.

> wrote

> > > > And it will be no more helpful...




> > > > > > alex, thanx man, btw, can u send me the complete doc sent by
> venkat? i
> > > guess
> > > > > > it wud be useful...

> > > > > Why not use a Google newsgroup search for this:

> http://groups.google.com/groups?as_ugroup=microsoft.public.scripting....
> > > uaut
> > > > hors=Venkat%20Reddy&as_scoring=d

> > > > > Direct link to the thread "win32_service Create fails with ret code
> 21":

> > > > > http://groups.google.com/groups?hl=en&th=dc1e4ee34d6b6e0d&rnum=1

> > > > > --
> > > > > torgeir



Mon, 27 Sep 2004 14:24:12 GMT  
 add / modify / delete service
alex,
    the problem is, i do not get any error for bRet. the service
successfully get's added to the service manager, but in the service, under
dependencies, RPC, which is a dependency does not get listed as a result the
service could not be started. the problem lies there...

muthu
---
Experience is a hard teacher because she gives the test first, the lesson
afterwards.


Quote:
> What are you getting for bRet?



> > hard luck...it did not work...'am still stuck...any helpers out there?

> > muthu

> > --
> > ---
> > Experience is a hard teacher because she gives the test first, the
lesson
> > afterwards.

wrote

> > > What are you getting for bRet?

> > > Post that if this doesn't help -

> > > I can't tell  whether anything special needs to be done when creating
a
> > service
> > > from script - the SDK only shows programming examples, and says that
the
> > > depended services at e a double null terminated string.  I don't know
if
> > this is
> > > handled behind the scenes or not, but you might try one of these:

> > > "rpcss"

> > > "rpcss" & vbNull

> > > "rpcss" & vbNull & vbNull



> > > > hey i can add the service now, thanx to everyone, but i again have a
> > > > problem, the service that i am trying to start depends on RPC
(rpcss).
> > when
> > > > i give the name in the dependencies array, it does not act any
> > different.
> > > > the dependency is not listed. i try it in the foll manner

> > > > bRet =

oSvc.Create("mTalk","mTalk","c:\winnt\system32\mtalk.exe",16,1,"Automatic",F
Quote:
> > > > alse,"domain\admin","password",NULL,NULL,["rpcss"])

> > > > please enlighten me on this. i am still stuck :((

> > > > muthu

> > > > --
> > > > ---
> > > > Experience is a hard teacher because she gives the test first, the
> > lesson
> > > > afterwards.
> > > > "Alex K. Angelopoulos"


- Show quoted text -

Quote:
> > wrote

> > > > > And it will be no more helpful...




> > > > > > > alex, thanx man, btw, can u send me the complete doc sent by
> > venkat? i
> > > > guess
> > > > > > > it wud be useful...

> > > > > > Why not use a Google newsgroup search for this:

http://groups.google.com/groups?as_ugroup=microsoft.public.scripting....

- Show quoted text -

Quote:
> > > > uaut
> > > > > hors=Venkat%20Reddy&as_scoring=d

> > > > > > Direct link to the thread "win32_service Create fails with ret
code
> > 21":

> > > > > > http://groups.google.com/groups?hl=en&th=dc1e4ee34d6b6e0d&rnum=1

> > > > > > --
> > > > > > torgeir



Mon, 27 Sep 2004 19:35:11 GMT  
 add / modify / delete service
You said that earlier; my apologies.

The quirks I am now seeing are these:

(1) I have nothing show up when I use your syntax - no errors, but no services
get added, either.
(2) If I yank the brackets, of course, mine now fails
(3) An earlier test that I did, leaving off all end items as optional, worked
flawlessly - go figure.

I'm trying to do some service queries now to see if I can determine how the
settings are echoed to VBScript; if we can see what comes out, we should know
what goes in.


Quote:
> alex,
>     the problem is, i do not get any error for bRet. the service
> successfully get's added to the service manager, but in the service, under
> dependencies, RPC, which is a dependency does not get listed as a result the
> service could not be started. the problem lies there...

> muthu
> ---
> Experience is a hard teacher because she gives the test first, the lesson
> afterwards.


> > What are you getting for bRet?



> > > hard luck...it did not work...'am still stuck...any helpers out there?

> > > muthu

> > > --
> > > ---
> > > Experience is a hard teacher because she gives the test first, the
> lesson
> > > afterwards.

> wrote

> > > > What are you getting for bRet?

> > > > Post that if this doesn't help -

> > > > I can't tell  whether anything special needs to be done when creating
> a
> > > service
> > > > from script - the SDK only shows programming examples, and says that
> the
> > > > depended services at e a double null terminated string.  I don't know
> if
> > > this is
> > > > handled behind the scenes or not, but you might try one of these:

> > > > "rpcss"

> > > > "rpcss" & vbNull

> > > > "rpcss" & vbNull & vbNull



> > > > > hey i can add the service now, thanx to everyone, but i again have a
> > > > > problem, the service that i am trying to start depends on RPC
> (rpcss).
> > > when
> > > > > i give the name in the dependencies array, it does not act any
> > > different.
> > > > > the dependency is not listed. i try it in the foll manner

> > > > > bRet =

> oSvc.Create("mTalk","mTalk","c:\winnt\system32\mtalk.exe",16,1,"Automatic",F
> > > > > alse,"domain\admin","password",NULL,NULL,["rpcss"])

> > > > > please enlighten me on this. i am still stuck :((

> > > > > muthu

> > > > > --
> > > > > ---
> > > > > Experience is a hard teacher because she gives the test first, the
> > > lesson
> > > > > afterwards.
> > > > > "Alex K. Angelopoulos"

> > > wrote

> > > > > > And it will be no more helpful...




> > > > > > > > alex, thanx man, btw, can u send me the complete doc sent by
> > > venkat? i
> > > > > guess
> > > > > > > > it wud be useful...

> > > > > > > Why not use a Google newsgroup search for this:

> http://groups.google.com/groups?as_ugroup=microsoft.public.scripting....
> > > > > uaut
> > > > > > hors=Venkat%20Reddy&as_scoring=d

> > > > > > > Direct link to the thread "win32_service Create fails with ret
> code
> > > 21":

> > > > > > > http://groups.google.com/groups?hl=en&th=dc1e4ee34d6b6e0d&rnum=1

> > > > > > > --
> > > > > > > torgeir



Mon, 27 Sep 2004 20:25:24 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Self Delete or modify

2. Delete out of process website package, IIS, Component Services

3. Using WMI to obtain dependent services (restarting services and all dependent services)

4. Add service in Outlook profile

5. Adding and Deleting from Arrays

6. script to add and delete users

7. Adding/Deleting users to windows 2000 Database

8. adding and delete printers

9. deleting data from a file, and then adding

10. Add/Delete Printers via WSH

11. Add/Delete records via VBScript

12. how to add a net use /delete to a WSH script

 

 
Powered by phpBB® Forum Software