Sign in to follow this  
Followers 0
zeng

Run DOS command from Autoit does not work

5 posts in this topic

I am new to this but ran into a problem that is very odd

I am trying to use this software http://www.pdflabs.com/tools/pdftk-server/ to rotate pdf files in a folder on a Win XP computer. When I ran the script below, nothing happened (no new rotated pdf file was created). But if I use the clipput in the script and paste to run command, it works (a new rotated pdf file was generated). I am at lost why the same command within autoit did not work

Thanks a lot for your help.

#include <File.au3>
$FileList = _FileListToArray("C:\Documents and Settings\zeng\Desktop\fax inbox\rotate\", "*.pdf", 1)
If $FileList[0] > 0 Then
    For $n = 1 To $FileList[0]
        If StringInStr($FileList[$n], "rotate") = 0 Then
            $mycommand = 'pdftk "C:\Documents and Settings\zeng\Desktop\fax inbox\rotate\' & $FileList[$n] & '" rotate 1-endsouth output "C:\Documents and Settings\zeng\Desktop\fax inbox\rotate\' & StringTrimRight($FileList[$n], 4) & ' rotated.pdf"'
            ClipPut(@ComSpec & " /c " & $mycommand); for trouble shot
            Run(@ComSpec & " /c " & $mycommand, "", @SW_HIDE)
        EndIf
    Next
EndIf

Share this post


Link to post
Share on other sites



It worked! You are a genius.

Share this post


Link to post
Share on other sites

This is only a suggestion; but since pdftk is an executable file you don't really need to be running it through cmd.exe (@Comspec /c)

#include <File.au3>
$FileList = _FileListToArray("C:\Documents and Settings\zeng\Desktop\fax inbox\rotate\", "*.pdf", 1)
If $FileList[0] > 0 Then
    For $n = 1 To $FileList[0]
        If StringInStr($FileList[$n], "rotate") = 0 Then
            $mycommand = 'pdftk "C:\Documents and Settings\zeng\Desktop\fax inbox\rotate\' & $FileList[$n] & '" rotate 1-endsouth output "C:\Documents and Settings\zeng\Desktop\fax inbox\rotate\' & StringTrimRight($FileList[$n], 4) & ' rotated.pdf"'
            ;ClipPut(@ComSpec & " /c " & $mycommand); for trouble shot
            Run($mycommand, "", @SW_HIDE)
        EndIf
    Next
EndIf

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
Sign in to follow this  
Followers 0