Page 1 of 2

Service will be sluggish when scrpit encounters error

Posted: Tue Sep 18, 2018 12:33 am
by jason@sbtc.com.tw
To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: PowerShell Studio 2018 v5.5.154
32 or 64 bit version of product: 64 bit
Operating system: Woindows 10
32 or 64 bit OS: 64 bit

*** Please add details and screenshots as needed below. ***

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

i build the service.
if get some error, the service look is running but it is not work.

Re: Service will be sluggish when scrpit encounters error

Posted: Tue Sep 18, 2018 3:34 am
by Alexander Riedel
"i build the service.
if get some error, the service look is running but it is not work."

I am sorry, but that is not enough information to determine what your problem might be.
"i build the service": I am assuming that means you packaged a script as a service? If so, with what options? For what platform?
"Some error": What exactly does that mean?
"it is not work": That can mean anything from doing nothing over rebooting your computer to causing a blackout in Singapore. Can you be more specific?

Maybe you can explain what your service does and WHERE it counters an error.

Re: Service will be sluggish when scrpit encounters error

Posted: Wed Sep 19, 2018 3:13 am
by jason@sbtc.com.tw
with what options? For what platform?
Script Engines:
Target : Microsoft Windows 64 bit.
SAPIEN Powershel V3 Host(windows Service)

"Some error": What exactly does that mean?
some file the name content @, example: 6X@CSKA[)JY5SJQ2(08-30-14-44-41).jpg

Example Code: $Filesarray = Get-ChildItem -path "$Workpath"
Remove-Item $Filesarray

it will to leader error, and the service will stop working but the service status is still in Running.
Will work normally after the service restarts.

Re: Service will be sluggish when scrpit encounters error

Posted: Wed Sep 19, 2018 3:44 am
by Alexander Riedel
You need to catch errors inside your script and handle them accordingly.
It is imperative that your script does not exit until a stop service command is issued. It is your responsibility to handle any errors in your script.
Just because your script stopped or crashed does not make the outer service wrapper stop or change its status.

Re: Service will be sluggish when scrpit encounters error

Posted: Wed Sep 19, 2018 4:30 am
by jason@sbtc.com.tw
However, if it works as a script, the script will not stop.

Re: Service will be sluggish when scrpit encounters error

Posted: Wed Sep 19, 2018 5:09 am
by Alexander Riedel
A service runs under a different account. Usually defaulting to the system account. Files or folder may not be accessible to that account, drives not mapped, network shares not available etc.
Without any information it is impossible to tell.

Re: Service will be sluggish when scrpit encounters error

Posted: Fri Sep 21, 2018 1:56 am
by jason@sbtc.com.tw
service-lab1.ps1
(613 Bytes) Downloaded 136 times
sourcefilder content 6X@CSKA[)JY5SJQ2(08-30-14-44-41).jpg and other files

I used try and catch, the service still stopped working. if get error.

This is not a permission issue.

The working directory in the c:\ drive.

i know is 6X@CSKA[)JY5SJQ2(08-30-14-44-41).jpg file name to leader this problem.

i hope to know how to keep the service working.

Re: Service will be sluggish when scrpit encounters error

Posted: Fri Sep 21, 2018 3:12 am
by Alexander Riedel
[Moved to PowerShell forum by moderator]

Re: Service will be sluggish when scrpit encounters error

Posted: Fri Sep 21, 2018 3:22 am
by jvierra
Jason. You are not trapping errors.

Can you please post the complete service script.

Re: Service will be sluggish when scrpit encounters error

Posted: Thu Sep 27, 2018 8:42 pm
by jason@sbtc.com.tw
jvierra wrote: Fri Sep 21, 2018 3:22 am Jason. You are not trapping errors.

Can you please post the complete service script.
has update in the before, you can't see?