Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Creating a new service using WIN32_service

Reply
 
Old 08-14-2007   #1 (permalink)
Nibor


 
 

Creating a new service using WIN32_service

Does anyone know of any articles that describe how to create a new service
using WIN32_Service? There are plently of examples of how to manipulate
existing services but haven't had any luck on doing a creation of a new one.



My System SpecsSystem Spec
Old 08-14-2007   #2 (permalink)
Hal Rottenberg


 
 

Re: Creating a new service using WIN32_service

On Aug 14, 10:38 am, Nibor <Ni...@discussions.microsoft.com> wrote:
> Does anyone know of any articles that describe how to create a new service
> using WIN32_Service? There are plently of examples of how to manipulate
> existing services but haven't had any luck on doing a creation of a new one.


Good exercise. Let's see, start here:

Create Method of the Win32_Service Class
http://msdn2.microsoft.com/en-us/library/aa389390.aspx

uint32 Create(
string Name,
string DisplayName,
string PathName,
uint8 ServiceType,
uint8 ErrorControl,
string StartMode,
boolean DesktopInteract,
string StartName,
string StartPassword,
string LoadOrderGroup,
string [] LoadOrderGroupDependencies,
string [] ServiceDependencies
);

I'm going to try to come up with some code myself, maybe someone can
beat me to it though.

My System SpecsSystem Spec
Old 08-14-2007   #3 (permalink)
Nibor


 
 

Re: Creating a new service using WIN32_service


To be a little more specific here I have tried the following:
ps> $service = [wmiclass]'win32_service'
ps> $newservice = $service.createinstance()

At this point I have tried multiple things: I have tried to assign all
properties like the following:
PS> $newservice.Name = "Service name"
etc...
it works fine until the put is tried I get this:
PS> $newservice.put()
Exception calling "Put" with "0" argument(s): "Exception calling "Put" with
"0" argument(s): "Unsupported parameter ""

I also tried to just call the create but I get this:

PS>$newservice.create('Service Name','Service Name','C:\Program
Files\Service.exe',16,0,'Auto',$False,'domain/user','','','','')
Exception calling "Create" : "Operation is not valid due to the current
state of the object."






"Hal Rottenberg" wrote:

> On Aug 14, 10:38 am, Nibor <Ni...@discussions.microsoft.com> wrote:
> > Does anyone know of any articles that describe how to create a new service
> > using WIN32_Service? There are plently of examples of how to manipulate
> > existing services but haven't had any luck on doing a creation of a new one.

>
> Good exercise. Let's see, start here:
>
> Create Method of the Win32_Service Class
> http://msdn2.microsoft.com/en-us/library/aa389390.aspx
>
> uint32 Create(
> string Name,
> string DisplayName,
> string PathName,
> uint8 ServiceType,
> uint8 ErrorControl,
> string StartMode,
> boolean DesktopInteract,
> string StartName,
> string StartPassword,
> string LoadOrderGroup,
> string [] LoadOrderGroupDependencies,
> string [] ServiceDependencies
> );
>
> I'm going to try to come up with some code myself, maybe someone can
> beat me to it though.
>
>

My System SpecsSystem Spec
Old 08-15-2007   #4 (permalink)
RichS


 
 

Re: Creating a new service using WIN32_service

Is there a reason for using Win32_Service rather than New-Service
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Nibor" wrote:

>
> To be a little more specific here I have tried the following:
> ps> $service = [wmiclass]'win32_service'
> ps> $newservice = $service.createinstance()
>
> At this point I have tried multiple things: I have tried to assign all
> properties like the following:
> PS> $newservice.Name = "Service name"
> etc...
> it works fine until the put is tried I get this:
> PS> $newservice.put()
> Exception calling "Put" with "0" argument(s): "Exception calling "Put" with
> "0" argument(s): "Unsupported parameter ""
>
> I also tried to just call the create but I get this:
>
> PS>$newservice.create('Service Name','Service Name','C:\Program
> Files\Service.exe',16,0,'Auto',$False,'domain/user','','','','')
> Exception calling "Create" : "Operation is not valid due to the current
> state of the object."
>
>
>
>
>
>
> "Hal Rottenberg" wrote:
>
> > On Aug 14, 10:38 am, Nibor <Ni...@discussions.microsoft.com> wrote:
> > > Does anyone know of any articles that describe how to create a new service
> > > using WIN32_Service? There are plently of examples of how to manipulate
> > > existing services but haven't had any luck on doing a creation of a new one.

> >
> > Good exercise. Let's see, start here:
> >
> > Create Method of the Win32_Service Class
> > http://msdn2.microsoft.com/en-us/library/aa389390.aspx
> >
> > uint32 Create(
> > string Name,
> > string DisplayName,
> > string PathName,
> > uint8 ServiceType,
> > uint8 ErrorControl,
> > string StartMode,
> > boolean DesktopInteract,
> > string StartName,
> > string StartPassword,
> > string LoadOrderGroup,
> > string [] LoadOrderGroupDependencies,
> > string [] ServiceDependencies
> > );
> >
> > I'm going to try to come up with some code myself, maybe someone can
> > beat me to it though.
> >
> >

My System SpecsSystem Spec
Old 08-15-2007   #5 (permalink)
Hal Rottenberg


 
 

Re: Creating a new service using WIN32_service

On Aug 15, 7:42 am, RichS <Ri...@discussions.microsoft.com> wrote:
> Is there a reason for using Win32_Service rather than New-Service


I don't know about Nibor but I want to do this against a remote
computer.

My System SpecsSystem Spec
Old 08-16-2007   #6 (permalink)
Nibor


 
 

Re: Creating a new service using WIN32_service

Me too. I have tried to Push-Location to a remote machine then run
New-service against it and it tries to create locally. I am still trying
though. If anyone has any ideas about using WIN32_Service instead please
post.

"Hal Rottenberg" wrote:

> On Aug 15, 7:42 am, RichS <Ri...@discussions.microsoft.com> wrote:
> > Is there a reason for using Win32_Service rather than New-Service

>
> I don't know about Nibor but I want to do this against a remote
> computer.
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
re: Creating an Installer for a Service and an Application .NET General
Creating a Windows Service .NET General
win32_service - Log On Tab PowerShell
Difference between get-service and wmi object win32_service PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46