Service will be sluggish when scrpit encounters error

Ask your Windows 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.
User avatar
jason@sbtc.com.tw
Posts: 24
Joined: Thu Apr 13, 2017 8:32 pm

Service will be sluggish when scrpit encounters error

Post by jason@sbtc.com.tw » Tue Sep 18, 2018 12:33 am

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: 6671
Joined: Tue May 29, 2007 4:43 pm

Re: Service will be sluggish when scrpit encounters error

Post by Alexander Riedel » Tue Sep 18, 2018 3:34 am

"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: 24
Joined: Thu Apr 13, 2017 8:32 pm

Re: Service will be sluggish when scrpit encounters error

Post by jason@sbtc.com.tw » Wed Sep 19, 2018 3:13 am

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: 6671
Joined: Tue May 29, 2007 4:43 pm

Re: Service will be sluggish when scrpit encounters error

Post by Alexander Riedel » Wed Sep 19, 2018 3:44 am

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: 24
Joined: Thu Apr 13, 2017 8:32 pm

Re: Service will be sluggish when scrpit encounters error

Post by jason@sbtc.com.tw » Wed Sep 19, 2018 4:30 am

However, if it works as a script, the script will not stop.

User avatar
Alexander Riedel
Posts: 6671
Joined: Tue May 29, 2007 4:43 pm

Re: Service will be sluggish when scrpit encounters error

Post by Alexander Riedel » Wed Sep 19, 2018 5:09 am

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: 24
Joined: Thu Apr 13, 2017 8:32 pm

Re: Service will be sluggish when scrpit encounters error

Post by jason@sbtc.com.tw » Fri Sep 21, 2018 1:56 am

service-lab1.ps1
(613 Bytes) Downloaded 9 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: 6671
Joined: Tue May 29, 2007 4:43 pm

Re: Service will be sluggish when scrpit encounters error

Post by Alexander Riedel » Fri Sep 21, 2018 3:12 am

[Moved to PowerShell forum by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
jvierra
Posts: 12773
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Service will be sluggish when scrpit encounters error

Post by jvierra » Fri Sep 21, 2018 3:22 am

Jason. You are not trapping errors.

Can you please post the complete service script.

User avatar
jason@sbtc.com.tw
Posts: 24
Joined: Thu Apr 13, 2017 8:32 pm

Re: Service will be sluggish when scrpit encounters error

Post by jason@sbtc.com.tw » Thu Sep 27, 2018 8:42 pm

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?

Post Reply