Simpel

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

23 posts in this topic

#1 ·  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

SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

No.


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

What is the result when adding the following to the end of your code:

ConsoleWrite($sPDFtk & " " & $sInputPDF & " stamp " & $sSig_1 & " output " & $sTempPDF & @CRLF)

 

Share this post


Link to post
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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
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.


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites

#10 ·  Posted

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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites

#11 ·  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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#13 ·  Posted

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

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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites

#14 ·  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.


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites

#15 ·  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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

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

Edited by Simpel

SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites

#18 ·  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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites

#19 ·  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)

 

Share this post


Link to post
Share on other sites

#20 ·  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

SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
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

  • Similar Content

    • e45678mail
      By e45678mail
      Hi~
      I have some question about how to enable the test mode via "Run" or "shellexecute" of command,
      was to tried :
      -----
      Run("bcdedit.exe /-set testsinging on", "C:\Windows\System32")
      and
      shellexecute("bcdedit.exe /-set testsinging on", "C:\Windows\System32")
      -----
      since this command must to run through administrator competence,
      have any method can accomplish it?
       
       
    • BlazerV60
      By BlazerV60
      Hello all,
      I've been trying to figure out how to launch Google Chrome in the background (hidden) but it doesn't seem possible. I've tried the following methods:
      ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", "", "", @SW_HIDE) Also I've tried:
      ShellExecute(@ComSpec, "/c start chrome.exe","","",@SW_HIDE) Lastly I tried:
      RunWait('"'&@ProgramFilesDir&'\Google\Chrome\Application\chrome.exe" --silent-launch',@ScriptDir)  
      But all of them launch my chrome browser without hiding it. Does anyone know a workaround for this or if AutoIT just can't Chrome? 
      Bonus points if you know how to make it launch chrome hidden and make it go to https://www.autoitscript.com
       
      Thank you,
      Brian
    • Miloud
      By Miloud
      How to get the result of the command?
      My code :
      Local $iRc = ShellExecute ( "G:\ffmpeg\bin\ffmpeg.exe" , "-version" , "G:\ffmpeg\bin\") ProcessWaitClose($iRc) $Message = StdoutRead($iRc)
    • breakbadsp
      By breakbadsp
      I want to run a python script from autoit. 
      I know we can do this with shellexecute or run , but this python script takes 3 cmd line arguments.
      How to pass them from autoit script?
      I tried many ways.
      Following solution also not working 
      e.g. 
      RunWait( 'fullpath\Python.exe Scriptpath\ReadLog.py  -f "file.log" -k "key" -e "errMsg" ') Found solution:
      RunWait( 'fullpath\Python.exe ReadLog.py -f "file.log" -k "key" -e "errMsg" ', 'Working_directory_path')  
      PFB description:
      https://stackoverflow.com/questions/45757834/how-to-pass-command-line-arguments-to-a-python-script-anyscript-while-executin
       
    • Mag91
      By Mag91
      Hey Community,
      cause im too new in the Auto it world i will try it with the your help. hopefully.
      I woud like to know how i can handle my Problem.
      ----
      I have a Excel Data with 362 random numbers.
      For Example:
      1166642335374 1172899897343
      .....
      this numbers are a part of the filepath ...example
      D:\Projekte\1166_64233_5374
      as u can see its the first number of the Excel data. After the first 4 numbers it shoud make a "_" than another 5 "_"
      This is my first question. How can i handle this to make it Shell execute.
       
      --------
      Second question:
      If i am in the path.
      For Example:
      D:\Projekte\1166_64233_5374
      the code shoud search for specific PDF Files.
      They are named like: 0050569E364B1ED79B900F73E62660EC.pdf
      the first 15 letters are always the same
      0050569E364B1ED
      when he found this data he has to copy it on a Folder on the Desktop.
      (There can also be 2 or 3 pdfs in one Folder with this letters)
      ----
      Please give me some help :-)