How to make your own Service using PowerShell

Welcome Forums General PowerShell Q&A How to make your own Service using PowerShell

This topic contains 4 replies, has 4 voices, and was last updated by

2 years, 7 months ago.

  • Author
  • #54245

    Points: 1
    Rank: Member

    Hi All,

    I have an executable file (MyTask.exe). Now I want to make it as a service so whenever we start it in services.msc it will start the exe file and so on.

    Can anyone have any idea how this can be done.

  • #54246

    Points: 1
    Rank: Member

    get-help New-Service

  • #54249

    Points: 1
    Rank: Member

    I tried with the below command, it created the Service in Services.msc

    PS C:\windows\system32> New-Service -Name "Test" -BinaryPathName "C:\Users\amarnath.mahato\Desktop\My Docz\Backup\Powe
    hell Scripts\Exe Files\LastBootUpTime.exe -k netsvcs" -DisplayName "Test" -StartupType Manual -Description "This is a
    st service."

    Now when I am trying to start it, it throwing the below ERROR :

    The Test service failed to start due to the following error:
    The service did not respond to the start or control request in a timely fashion.

    Error code -> 1053

    Any suggestion on this.. I am running is locally, and am local admin as well?

  • #54257

    Points: 0
    Rank: Member

    You can't just run any old executable file as a service directly. They have to be written to work that way. If you want to run something else as a service, there's an old tool called SrvAny.exe that can help with that.

  • #54259

    Points: 24
    Team Member
    Rank: Member

    As Dave mentioned SrvAny is very old and I believe only available in equally old Windows resource kits which are difficult to get these days. You can download and use a tool which provides the same functionality but it is still under active development call NSSM – the Non-Sucking Service Manager.

The topic ‘How to make your own Service using PowerShell’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort