![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Powershell Script as Windows Service Hello everybody, i am wondering if it is possible to run powershell scripts as windows service? embedding my *.ps1 script in a batch file and using instsrv/srvany allows me to start up my *.ps1 script but when i stop the service, it seems to stop the running *.bat but not the contained *.ps1 Application... Any hints? |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: Powershell Script as Windows Service because you are starting the batch file with srvany it is the bat file thats treated as the service. I think that when the bat file starts PowerShell it spawns another process outside the service. the service doesn't know anything about it so leaves powershell running. you would need to start powershell as the service and put in the script you want to run as a parameter -- 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 "tobias.kuhn@gmail.com" wrote: > Hello everybody, > > i am wondering if it is possible to run powershell scripts as windows > service? > embedding my *.ps1 script in a batch file and using instsrv/srvany > allows me to start up my *.ps1 script but when i stop the service, it > seems to stop the running *.bat but not the contained *.ps1 > Application... > > Any hints? > > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Powershell Script as Windows Service How did you launch the powershell session via the batch file? -- Brandon Shell --------------- Stop by my blog some time ![]() http://www.bsonposh.com/ Try the "Search of Powershell Blogs" -------------------------------------- <tobias.kuhn@gmail.com> wrote in message news:1170949835.557854.291350@q2g2000cwa.googlegroups.com... > Hello everybody, > > i am wondering if it is possible to run powershell scripts as windows > service? > embedding my *.ps1 script in a batch file and using instsrv/srvany > allows me to start up my *.ps1 script but when i stop the service, it > seems to stop the running *.bat but not the contained *.ps1 > Application... > > Any hints? > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Powershell Script as Windows Service That would only be the case if he used: start C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command script.ps1 If he has this in the batch it should block and powershell should terminate when cmd.exe is killed. powershell -command script.ps1 Maybe he can post the script -- Brandon Shell --------------- Stop by my blog some time ![]() http://www.bsonposh.com/ Try the "Search of Powershell Blogs" -------------------------------------- "RichS" <RichS@discussions.microsoft.com> wrote in message news ABF7B12-F851-4514-96D5-B3B555D166AF@microsoft.com...> because you are starting the batch file with srvany it is the bat file > thats > treated as the service. I think that when the bat file starts PowerShell > it > spawns another process outside the service. the service doesn't know > anything about it so leaves powershell running. > > you would need to start powershell as the service and put in the script > you > want to run as a parameter > -- > 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 > > > "tobias.kuhn@gmail.com" wrote: > >> Hello everybody, >> >> i am wondering if it is possible to run powershell scripts as windows >> service? >> embedding my *.ps1 script in a batch file and using instsrv/srvany >> allows me to start up my *.ps1 script but when i stop the service, it >> seems to stop the running *.bat but not the contained *.ps1 >> Application... >> >> Any hints? >> >> |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Powershell Script as Windows Service On 8 Feb., 18:04, "Brandon Shell" <tshell.m...@gmail.com> wrote: > How did you launch the powershell session via the batch file? > > -- > Brandon Shell > --------------- > Stop by my blog some time http://www.bsonposh.com/> Try the "Search of Powershell Blogs" > -------------------------------------- > > <tobias.k...@gmail.com> wrote in message > > news:1170949835.557854.291350@q2g2000cwa.googlegroups.com... > > > Hello everybody, > > > i am wondering if it is possible to run powershell scripts as windows > > service? > > embedding my *.ps1 script in a batch file and using instsrv/srvany > > allows me to start up my *.ps1 script but when i stop the service, it > > seems to stop the running *.bat but not the contained *.ps1 > > Application... > > > Any hints? Hi all, i started my test.ps1 in a run.bat like Powershell C:\test.ps1 With this run.bat i "created" a Windows Service with instsrv and srvany... the usual way. I solved the problem of "stopping" the service including the powershell script by using "powershell C:\test.ps1" in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aaaa \Parameters "Application" Key --> now when i stop the Service (here: aaaa) , also the powershell script seems to be stopped. So the solution is not to use the "integration" of a powershell script in a batch file when it should be run as a windows service. Just create your Service with "instsrv" and "srvany" the usual way and use "powershell myscript.ps1" in the registry... |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Powershell Script as Windows Service Very Nice... still curious that it didn't work as expected. -- Brandon Shell --------------- Stop by my blog some time ![]() Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject -------------------------------------- <tobias.kuhn@gmail.com> wrote in message news:1170955656.944022.247230@q2g2000cwa.googlegroups.com... > On 8 Feb., 18:04, "Brandon Shell" <tshell.m...@gmail.com> wrote: >> How did you launch the powershell session via the batch file? >> >> -- >> Brandon Shell >> --------------- >> Stop by my blog some time http://www.bsonposh.com/>> Try the "Search of Powershell Blogs" >> -------------------------------------- >> >> <tobias.k...@gmail.com> wrote in message >> >> news:1170949835.557854.291350@q2g2000cwa.googlegroups.com... >> >> > Hello everybody, >> >> > i am wondering if it is possible to run powershell scripts as windows >> > service? >> > embedding my *.ps1 script in a batch file and using instsrv/srvany >> > allows me to start up my *.ps1 script but when i stop the service, it >> > seems to stop the running *.bat but not the contained *.ps1 >> > Application... >> >> > Any hints? > > Hi all, > > i started my test.ps1 in a run.bat like > Powershell C:\test.ps1 > With this run.bat i "created" a Windows Service with instsrv and > srvany... the usual way. > > I solved the problem of "stopping" the service including the > powershell script by using > > "powershell C:\test.ps1" > > in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aaaa > \Parameters "Application" Key > > --> now when i stop the Service (here: aaaa) , also the powershell > script seems to be stopped. > > So the solution is not to use the "integration" of a powershell script > in a batch file when it should be run as a windows service. > Just create your Service with "instsrv" and "srvany" the usual way and > use "powershell myscript.ps1" in the registry... > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can a Windows Service run a visual basic script? | David | .NET General | 2 | 03-26-2008 07:04 AM |
| What is the MIME type of Windows Powershell script files (.ps1 fil | zkyboy | PowerShell | 3 | 03-11-2008 07:37 AM |
| when run powershell script as windows service ,powershell fail | powershell fail on winodws 2008 | PowerShell | 6 | 01-15-2008 03:20 PM |
| Powershell or Windows Script | Marc Sommer | PowerShell | 3 | 12-05-2007 03:20 PM |
| Script Host Client launched from Windows Service | DavidRF | Vista security | 4 | 06-27-2007 04:01 PM |