Service will be sluggish when scrpit encounters error

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jason@sbtc.com.tw
Posts: 26
Last visit: Wed Jan 17, 2024 11:18 pm

Service will be sluggish when scrpit encounters error

Post 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.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Service will be sluggish when scrpit encounters error

Post 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.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
jason@sbtc.com.tw
Posts: 26
Last visit: Wed Jan 17, 2024 11:18 pm

Re: Service will be sluggish when scrpit encounters error

Post 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.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Service will be sluggish when scrpit encounters error

Post 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.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
jason@sbtc.com.tw
Posts: 26
Last visit: Wed Jan 17, 2024 11:18 pm

Re: Service will be sluggish when scrpit encounters error

Post by jason@sbtc.com.tw »

However, if it works as a script, the script will not stop.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Service will be sluggish when scrpit encounters error

Post 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.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
jason@sbtc.com.tw
Posts: 26
Last visit: Wed Jan 17, 2024 11:18 pm

Re: Service will be sluggish when scrpit encounters error

Post 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.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Service will be sluggish when scrpit encounters error

Post by Alexander Riedel »

[Moved to PowerShell forum by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Service will be sluggish when scrpit encounters error

Post by jvierra »

Jason. You are not trapping errors.

Can you please post the complete service script.
User avatar
jason@sbtc.com.tw
Posts: 26
Last visit: Wed Jan 17, 2024 11:18 pm

Re: Service will be sluggish when scrpit encounters error

Post 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?
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked