Jump to content

[Solved]: @ScriptDir + space in parameter FileGetShortName not working


Simpel
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • Developers

For starters: So how did you determine that FileGetShortName() is not working?  what was the returned string?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Developers

What kind of disk/volume is the mapped H: drive? Does it show shortnames when doing the dir /X ?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...