Jump to content
Simpel

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

Recommended Posts

Simpel

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 = 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
water

Does it work when you add quotes?

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

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Simpel

No.


SciTE4AutoIt = 3.7.3.0   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
water

Maybe relative path works:

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

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jos

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

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Subz

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
Simpel

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 = 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
Simpel

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 = 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
Simpel

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 = 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
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Simpel

@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 = 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
Simpel

@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 = 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
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Simpel

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 = 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
Simpel

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 = 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
Subz

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
Simpel

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 = 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

    • rudi
      By rudi
      Hello,
      for a script to display PDF files I'd like to simply use the default program for PDF files, so I used "ShellExecute(<pdf-file-full-path>)" to open these files.
       
      The result for *SOME* of the workstations is, that the Adobe Reader starts up with asking for its language. (English/German). When starting AcroRd32.exe through "ShellExecute()", this "choose your language" dialog is showing up *ALWAYS*.
       
      Just to have mentioned it: Process Explorer is presenting this command line, it looks the same for both, PCs with and without that question "Choose Language? [English|German]"
      "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" --channel=4680.0.860715181 --type=renderer "\\pc0009\Y_DRV_H\Daten\TIF\08\32\G000110832_Freigegeben.idw.pdf"  
      The next approach I thought of was to use Foxit Portable (instead of Acrord32.exe), started from a Network Drive, but it's starting up ugly slowly...
      So I tried to "Run()" instead to "ShellExecute()" the Adobe Reader. Now the result looks more stange, the "select your language" dialog shows up every now and then, but not always for the Win7 installations affected.
       
      If I place a "msgbox()" just in front of the "run()" command, it seems never to show this "select your language" dialog.
      If I take out this MsgBox() the "select your language" dialog shows up sometimes.
      When I "ClipPut()" the run command prior the "Run()" and paste that one to a CMD box, then it seems to *NEVER* happen, that this "select your language" dialog shows up.
       
      "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" "\\pc0009\Y_DRV_H\Daten\TIF\08\32\G000110832_Freigegeben.idw.pdf" $AcroRead='"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"' $PDF='"Y:\Temp\DRV_H\Daten\TIF\33\85\153385_Freigegeben.dwg.pdf"' MsgBox(0,"Values",$AcroRead & @CRLF & $PDF,1) $MyCommand=$AcroRead & " " & $PDF ClipPut($MyCommand) Run($MyCommand)  
      It looks like, that this "--channel=... --type=renderer" parameters are always fact for the AcroRd32.exe instance, that is opening the PDF to be displayed. The Instance opening the "PDF Display GUI" seems to always be a child process of another AcroRd32.exe process.
       
      Any clue, what's going on "backstage" here? How to avoid this "Choose your language" dialog? Or maybe someone can mention a different "portable" PDF viewer, I could use for this purpose?  
      Any suggestions appreciated, regards, Rudi.
    • 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
       
×