OL Learn

Problem with executing shell command using services, works in debug

Hello

I have problem with Planet Press Connect project where I would like to execute Shell.Object from VBS script.

For example we have:

Option Explicit

Dim  shl

Set shl = CreateObject("Shell.Application")

shl.ShellExecute "notepad.exe", "", "", "open", 1

And when I run this script using DEBUG mode then Notepad will be opened correctly.
When want to use Planet Press services, then cant.

Also inside Event VIewer have following errors:

The description for Event ID 1 from source PPWatch8 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

Please help me, what to do.

It would be attempting to open notepad for the service account in a non-interactive desktop session. Even if it were to open, you’d never see it since it would be in the service account’s session and not yours. Logging in as the service account won’t help either, again because Windows keeps these sessions separated.

What are you trying to do with notepad, exactly? Or is that just an example? What’s your real goal here?

The Notepad is just an example, I am sending PDF documents to printer using Shell Execute script.

It works fine without any issues in debug mode, but when I want to use service to run Planet Press project, it stuck on this script. (Hangs) and nothing is sent to printer.

It looks like this:

Set shl = CreateObject("Shell.Application")

'send all files to printer
for i = 0 to Ubound(filesName)-1
        shl.ShellExecute filesName(i), "", "", "print", 0
next

Its WIndows 10 environement, 64 bit, user is admin

Try setting the Run on desktop option to true for your process and see if that works.
More info here: https://help.objectiflune.com/en/pres-workflow-user-guide/2020.1/Default.html#Workflow/ProcessSubprocess/Toggle_Run_Desktop_Property.html?Highlight=interact

Phil

Thank You for idea but changing this option to TRUE not working

Whenever you use ShellExecute, an application opens up in order to print (even it it is “invisible”, it still opens up). This application is almost certainly attempting to display a dialog window, but you cannot see that window because a service runs on a different desktop than the normal user desktop.

You will probably tell me that in debug mode, the application doesn’t display any dialogs, so there’s no reason why it would display one in service mode. But the problem is: you don’t know that! Perhaps there is no default printer available to the service session. Or it might be some other kind of confirmation.

Anyway: run the process in service mode. Once the process gets “stuck”, open the Windows Task manager and look for the executable application that has opened up in order to print the file (e.g. if it’s an xls file, look for Excel), and then kill that task: your process should resume. Obviously, if the process has captured several files, you’ll need to kill the task as many times as there are files, so run the test with a single file.
That should demonstrate that the issue is with the external application waiting for some kind of input, which you can’t provide.

Well but it works fine in debug, but the files are not sent to Printer Queue using Services

I think it can be something more like about Local User and Services User

I am using user as “ppuser” which is Windows User Administrator
The Planet Press Services are also configured to use .\ppuser

Any other ideas?

Did you run the test I requested in my previous post? Did you see the app started in Task Manager? Did killing that task “unfreeze” the Workflow process?

YES, I run test and kill it, nothing happens, just stack.

Finally we resolved that by using SUMATRA portable PDF instead of ADOBE.

When You switch to SUMATRA there is no issue with sending documents into print queue from services and debug mode.

You need to paste SUMATRA PDF into Resources for example.

You’re printing PDF’s? You know that you can do that naively by sending the PDF to a Windows Printer queue defined in Workflow, right?

Yes, but there is more complex logic besides this

I had to use Adobe instead of SUMATRA PDF

SUMATRA had problems with XFA pdf documents.

The solution to this problem is that You have to disable Adobe enhanced security option.
(Inside Adobe software Settings)

If You disable this option then everything works fine using services.

Thanks
Adam

Thanks for sharing the solution!

1 Like

Thank You also for all suggestions :slight_smile: