Add this line to your script:
It suppresses all dialogs. Be sure to add this line at the end of your script:
Or even better, use it in the catch phrase of a try-catch construction.
I had a script running fine called from a Windows service using doScript. All of a sudden it stopped working throwing the error "Cannot handle the request because a modal dialog or alert is active". I tried setting the userInteractionLevel as described here in the script with the same result. I tried setting the userInteractionLevel on the com object in my c# code with the same result. I even tried making a test script that just creates a new document. I ran it in the UI with no problem, but got the same result when trying to run it from the service. I even uninstalled and reinstalled CS5. I don't see an option in the CS5 com object to show the window when running a script. I'm out of ideas and very stuck. Can anyone help?
I know you said you already tried it, but I would try running the script with indesign open so you can see what the problem is. Dialogs can still apear, even after you say 0 interaction, it happenes. Maybe your script creates a file dialog or something?
Did that. No luck. I tried a test script whose entire code is below. It runs fine in the UI, but produces the same error when executed from COM.
var doc = app.documents.add( true, app.documentPresets.itemByName( "[Default]" ) );
I even did a bare metal reinstall of CS5.
The same script & C# invocation of it works fine on a server I'm using for testing.
Is there a way to call doScript from COM and have it show the window? I believe there used to be in CS3.
In case anyone else experiences this, I hope to save you the week of pain it caused me. It turns out the dialog was about recovering a document. The only was I could get past it was a trick our IT guy figured out. He showed me how to run Windows as the System user. Once I did that, I was able to run InDesign as the System user and manually dismiss the dialog.
Here's what our IT guy figured out for Vista/Win7:
- Download and install PSTools from Microsoft: http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
Launch cmd.exe as administrator
Run psexec -i -s c:\windows\system32\cmd.exe
In new command window type explorer.exe
For anyone who comes across this looking for how to suppress errors in Photoshop CC, I found this worked:
app.displayDialogs = DialogModes.NO;
// Your code
app.displayDialogs = DialogModes.ERROR;