Jump to content

Recommended Posts

Posted (edited)

Hi.

Local $sPDFtk = FileGetShortName(@ScriptDir & "\pdftk.exe")
Local $sInputPDF = FileGetShortName(@ScriptDir & "\Prodis_Test.pdf")
Local $sSig_1 = FileGetShortName(@ScriptDir & "\Sig_1.pdf")
Local $sTempPDF = FileGetShortName(@ScriptDir & "\Prodis_Test_TEMP.pdf")

$iSuccess = ShellExecuteWait($sPDFtk, $sInputPDF & " stamp " & $sSig_1 & " output " & $sTempPDF, "", "", @SW_HIDE)

@ScriptDir is "H:\_Conrad lokal\Downloads\AutoIt3\_COX". As you can see there is a space in the path.

I know that ShellExecuteWait is working with FileGetShortName at the filename. It seems to me that I can't pass the parameters that way. But without FileGetShortName it's not working too.

Ideas? Regards, Conrad

Edited by Simpel
SOLVED
SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

Does it work when you add quotes?

Local $sPDFtk = FileGetShortName("'" & @ScriptDir & "\pdftk.exe'")

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

No.

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

Maybe relative path works:

Local $sPDFtk = FileGetShortName(".\pdftk.exe", 1)
Consolewrite("@Error: " & @Error & @CRLF)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

The returned strings are:

@@ Debug(8) : $sPDFtk = H:\_Conrad lokal\Downloads\AutoIt3\_COX\AA\pdftk.exe
>Error code: 0
@@ Debug(10) : $sInputPDF = H:\_Conrad lokal\Downloads\AutoIt3\_COX\AA\Prodis_Test.pdf
>Error code: 0
@@ Debug(12) : $sSig_1 = H:\_Conrad lokal\Downloads\AutoIt3\_COX\AA\Sig_1.pdf
>Error code: 0
@@ Debug(15) : $sTempPDF = H:\_Conrad lokal\Downloads\AutoIt3\_COX\AA\Prodis_Test_TEMP.pdf
>Error code: 1

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

If I do it this way:

RunWait($sPDFtk & " " & $sInputPDF & " stamp " & $sSig_1 & " output " & $sTempPDF, "", @SW_HIDE, $STDOUT_CHILD)

console says:

Error: expecting "output" keyword.  Instead, I got:
   lokal\Downloads\AutoIt3\_COX\AA\Sig_1.pdf
Errors encountered.  No output created.
Done.  Input errors, so no output created.

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

No dir /x shows no shortnames. H: drive is my network homedrive.

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

The help file for RunWait tells us: "Paths with spaces need to be enclosed in quotation marks."
So you need to enclose all paths in quotes:

RunWait("'" & $sPDFtk & "' '" & $sInputPDF & "' stamp '" & $sSig_1 & "' output '" & $sTempPDF & "'", "", @SW_HIDE, $STDOUT_CHILD)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

As all files except $sTempPDF return @error = 0 it is not a problem with FileGetShortName.
I assume $sTempPDF does not exist when you run PDFTk.

Unfortunately FileGetShortName needs the file to exist to get the proper short name. Please see the help file for details.
Why don't you use a short name like

Local $sTempPDF = @ScriptDir & "\TempPDF.pdf"

for the output file?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

@water: relative path and enclose all paths in quotes for run did not work. Return is:

@@ Debug(23) : $iSuccess = 0
>Error code: 1

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

@water: yes you're right $sTempPDF is made by the programm I want to execute. It's the output file. I even tested it with Local $sTempPDF = @ScriptDir & "\TempPDF.pdf" but the problem isn't the filename I guess but the path.

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

I can't test at the moment but I think this could work:

Local $sPDFtk = FileGetShortName(@ScriptDir & "\pdftk.exe")
Local $sInputPDF = FileGetShortName(@ScriptDir & "\Prodis_Test.pdf")
Local $sSig_1 = FileGetShortName(@ScriptDir & "\Sig_1.pdf")
Local $sTempPDF = '"' & @ScriptDir & '\TempPDF.pdf"')

RunWait($sPDFtk & ' ' & $sInputPDF & ' stamp ' & $sSig_1 & ' output ' & $sTempPDF, '', @SW_HIDE, $STDOUT_CHILD)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

I had to delete ) at Local $sTempPDF to have proper syntax but anyway it's not working.

Edited by Simpel
SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

Puh,

Opt('ExpandVarStrings', 1) works. Now I have to be careful using $ or @ in messageboxes etc. Don't think I will need them here or will use $$ and @@.

Thank you all for your replies and help.

Regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted

I don't believe Opt('ExpandVarStrings', 1) would be the fix, I just prefer to write vars in strings especially when I have to add lots of quotes for example this works for me as well:

Local $sPDFtk = @ScriptDir & "\pdftk.exe"
Local $sInputPDF = @ScriptDir & "\Prodis_Test.pdf"
Local $sSig_1 = @ScriptDir & "\Sig_1.pdf"
Local $sTempPDF = @ScriptDir & "\Prodis_Test_TEMP.pdf"

RunWait('"' & $sPDFtk & '" "' & $sInputPDF & '" stamp "' & $sSig_1 & '" output "' & $sTempPDF & '"', "", @SW_HIDE)

 

Posted (edited)

This works too. So it is a question of where to put the right kind of quote at the right point. So this works too:

ShellExecuteWait($sPDFtk, '"' & $sInputPDF & '" stamp "' & $sSig_1 & '" output "' & $sTempPDF & '"', "", "", @SW_HIDE)

Thanks for replying this. So I could handle it that way I wanted. I hope I will keep that in mind. Quotes sometimes makes me crazy.

Edited by Simpel
Deleted one wrong sentence
SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...