about Java launch ps-script, can not close error box!

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

beauty9235

about Java launch ps-script, can not close error box!

Post by beauty9235 »

now for my system, I need use java to launch ps-script.
I have managed to do in platform winxp(win cmd and java), but the problem is that it can not work in win 2008 server. I guess it's the access right, something with firewall.
Javacode to Invoke ps-script:
Code: Select all public static void process(String cmd) {
        log.debug(cmd);
        String[] cmdAttributes = new String[]{"cmd.exe", "/C", cmd};
        Process p = null;
        InputStream br = null;
        try {
            ProcessBuilder pb = new ProcessBuilder(cmdAttributes);
            pb.redirectErrorStream(true);
            p = pb.start();
            br = p.getInputStream();
            StreamGobbler outputGobbler = new StreamGobbler(br, "Output");
            outputGobbler.start();
            p.waitFor();
        } catch (Throwable ex) {
            log.debug(ex);
        } finally {
            IOUtils.closeQuietly(br);
            if (p != null) {
                p.destroy();
            }
        }
    }

how to invoke my ps-script:
actually it can not invoke the ps-script(javascript directly), but we can use an mid-script, vb script to invoke ps-script
Code: Select allSet vbsArguments = WScript.Arguments
If vbsArguments.Length = 0 Then
WScript.Echo "Argument(0) is `your script to execute"
WScript.Echo "Arguments(0+n) are passed to your script as argument(0) to argument(n-1)"
Else
ReDim jsxArguments(vbsArguments.length-2)

for i = 1 to vbsArguments.length - 1
jsxArguments(i-1) = vbsArguments(i)
Next

Set photoshop = CreateObject( "Photoshop.Application" )
photoshop.BringToFront
'DoJavaScript has 3 parameters
' syntax DoJavaScript(arg[0], arg[1], arg[2]]
'arg[0] == javascript file to execute, full pathname
'arg[1] == an array of arguments to past to the javascript
'arg[2] == AiJavaScriptExecutionMode: aiNeverShowDebugger = 1,, aiDebuggerOnError = 2 aiBeforeRunning = 3
' only use 1
Call photoshop.DoJavaScriptFile(vbsArguments(0), jsxArguments, 1)
End IF

now we use like:
Code: Select all 
cmd= " \""+cf.getWebPath()+"\\ps-script\\DoJavaScriptFile.vbs\" "+cmd;
ExecuteCommand.process(cmd);

the cmd just like \c\test\resize.jsx
also you can attach some parameters like width, height and so on

My codes can work in winxp,but win 2008 can not work, any body can help me or give me some advice?
I means if ps encounters some errors box like "This document may be damaged", the ahk script can not close the error box automately until some one login on server2008, do nothing, but then it will begin to work. strange, Anybody has some ideas?