Creating Windows Service

I am working on creating a simple windows service. I believe my script works; however, if anyone could critic and give some new suggestions, it will be greatly appreciated.

if {exists service whose (service name of it as lowercase = (parameter “ServiceName” of action as lowercase)}
wait cmd /c sc create servicename binpath= “%windir%\securedfolder\servicename.exe” start=“auto” displayname="servicename"


Verify the permissions of the folder to ensure that the service is properly allowed to run. Is running in ‘system’ context ok? Or do you need to run it as a service account? If service account, then the file system permissions and OS delegations will both need to align for it to run correctly.