Java ProcessBuilder and VBS script issue
<p>Am going round in circles here trying to execute a bit of VBScript from java using processbuilder.  I'm running my java code as part of a tomcat servlet.  If I run the same command from a command line - its running fine.  Have tried opening permissions right up (everyone=full perms)</p>

<p>Java Code (excerpt):</p>

<pre class="lang-java prettyprint-override"><code>ProcessBuilder pb = new ProcessBuilder("cscript", "C:\\Users\\Public\\Documents\\office2pdf.vbs", "C:\\Users\\Public\\Documents\\temp\\22.doc");
Process pr = pb.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String line = null;
StringBuilder sb = new StringBuilder("");
while ( (line = reader.readLine()) != null) {
    sb.append(line);
}
int i = pr.waitFor() ;
getServletContext().log("pb response="+i+", er="+sb.toString());
</code></pre>

<p>VBScript (excerpt):</p>

<pre class="lang-vb prettyprint-override"><code>Sub SaveWordAsPDF(p_strFilePath)
    'Save Word file as a PDF

    'Initialise
    Dim objWord, objDocument
    Set objWord = CreateObject("Word.Application")
     Wscript.Echo p_strFilePath
    'Open the file
    Set objDocument = objWord.Documents.Open(p_strFilePath)

    'Save the PDF
    objDocument.SaveAs PathOfPDF(p_strFilePath), WORD_PDF

    'Close the file and exit the application
    objDocument.Close FALSE
    objWord.Quit
End Sub
</code></pre>

<p>I've traced it as far to see that the vbscript is infact loading; the line 'Wscript.Echo p_strFilePath' does in fact actually print the correct path to the word doc.  According to the error stream returned from java the offending line from vbscript is: 'Set objDocument = objWord.Documents.Open(p_strFilePath)' for which its saying: </p>

<p>Microsoft VBScript runtime error: Object required: 'objWord.Documents.Open(...)'</p>

<p>not sure if this is only triggered from incomplete path; looked at lots of posts - haven't been able to find any that exactly match my situation.  Any advice is greatly appreciated!</p>