0
I am trying to print all files in certain format (i.e. *.xmcd
) in a folder to PDF. I already made AdobePDF my default printer. I want to do this task using powershell but I when I run it I get the an error, which I think has to do something with Mathcad software.
I also added VBScript
tag since as I am moving forward with this. I more think about using visual basic for this purpose.
This is the command:
Start-Process -FilePath “internal.company.com\path\to\the\file.xmcd” –Verb Print -PassThru | %{sleep 10;$_} | kill
And the error that I get:
It basically should get the file, start printing and after 10 seconds close the application.
I also tried cygwin and cygstart
like below but it gives me an error;
cygstart --print myfile.xmcd
and the error is: Unable to start 's.xmcd': The DDE transaction failed.
First step is to figure out a way to print mathcad sheet using powershell or batch/bash script.
Note: Mathcad sheets have XML format.
Note-2: Out-Print
gives a pdf of the xml.
Note-3: cmd.exe /C ASSOC .xmcd
gives me .xmcd=Mathcad
.
And, cmd.exe /c ftype Mathcad
gives me Mathcad="C:\Program Files (x86)\Mathcad\Mathcad 15\mathcad.exe" /dde
.
What is the output of the command
& cmd.exe /C ASSOC .xmcd
? Have you investigatedOut-Printer
? – lit – 2017-05-08T17:34:23.307@lit
Out-Printer
prints the XML format of the file. I think I need to somehow open the file with Mathcad.exe and then print it. – M-- – 2017-05-08T17:47:58.860@lit I added output of
cmd.exe /C ASSOC .xmcd
in the question. – M-- – 2017-05-08T17:51:40.057What is the output of
& cmd.exe /c ftype Mathcad
? – lit – 2017-05-08T18:02:22.823@lit
Mathcad="C:\Program Files (x86)\Mathcad\Mathcad 15\mathcad.exe" /dde
– M-- – 2017-05-08T18:05:33.167Does the simple example in the Start-Process help work?
Start-Process -FilePath "myfile.txt" -WorkingDirectory "C:\PS-Test" -Verb Print
– lit – 2017-05-08T18:09:59.490It does work. but not for the
.xmcd
file of course. For a text file it does its job with no error. – M-- – 2017-05-08T18:12:33.843Please try quoting the -Verb.
-Verb "Print"
– lit – 2017-05-08T18:41:44.610@lit It does give me the same error. It opens mathcad but the sheet won't load. and no print out. – M-- – 2017-05-08T18:46:08.707
Please try specifying the -FilePath with
"\\internal.company.com\path\to..."
or with"\\SERVERNAME\SHARENAME\path\to..."
or with"D:\path\to..."
. – lit – 2017-05-08T18:53:54.260@lit already tried that with different path and etc. – M-- – 2017-05-08T18:55:03.487
My apologies. I will not waste more of your time until I have something in which I have more confidence. – lit – 2017-05-08T19:12:43.060
@lit No worries. Thanks for your time and help. – M-- – 2017-05-08T19:13:37.917
@lit It'd be great if you could take a look at my answer. You may be able to help me with the next step. – M-- – 2017-05-09T21:10:24.770