Jump to content

Really stuck working with Run(


Recommended Posts

Hey everyone, me and the Run( command have been going round and round, with Run( winning all the battles so far.

I'm making a nice little script that gathers all the drag and dropped files and builds them into a long string, and then runs that within a Cmd prompt with the copy command.

I've been getting nowhere with it for a few hours now, and just for my own sanity, completely hard coded my Run( statement, and was blow away, that even that isn't working.

Here's my offending line; what am I doing wrong?

Run("C:\Windows\system32\cmd.exe /C copy C:\Test\1.dat + C:\Test\2.dat + C:\Test\3.dat + C:\Test\4.dat + C:\Test\5.dat C:\Test\2011.eml", @SW_HIDE)

Like I said, that line above is purely written as hard code because I was up agaist a wall and wanted to see if even that would work...which it didn't. My normal line is,

$cmdreturn = RunWait(@ComSpec & " /C " & $SuperString, @SW_HIDE)

Thanks

Link to comment
Share on other sites

You left out a parameter.

You might also want to use the /a switch if they are not binary files.

Run(@Comspec & " /c /a " & $SuperString, "", @SW_HIDE)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

You could probably just do it from within AutoIt. If you put your files into an array, instead of constructing a string, you can do it this way:

$outfile = FileOpen("c:\test\2011.eml", 2 + 8)
For $i = 1 To UBound($filelistarray)
    $infile = FileRead($filelistarray[$i - 1])
    FileWrite($outfile, $infile)
Next
FileClose($outfile)

---Edit---

fixed typo

Edited by willichan
Link to comment
Share on other sites

You could probably just do it from within AutoIt. If you put your files into an array, instead of constructing a string, you can do it this way:

$outfile = FileOpen("c:\test\2011.eml", 2 + 8)
For $i = 1 To UBound($filelistarray)
    $infile = FileRead($filelistarray[$i - 1])
    FileWrite($outfile, $infile)
Next
FileClose($outfile)

---Edit---

fixed typo

Okay, now this is interesting, and let me get your feedback on this.

What this script does it seam broken email ".DAT" files back together and save it as a plain text email (eml file) I didn't do it within program because I wasn't sure if the script should be playing with, at times nearly 80 MB of data split over 40 files. The current office scanner can save your scan as a PDF and then email it back to your outlook, however it hits a size limit of 2mb, and then breaks the email, so we get a lot of files that look like "Message from _RNP0026731C1856_ part 01_24.dat" and each dat file is exactly 2mb, but when they're all pasted together and then the file extension changed to eml, they open and the scanned PDF attachment is fine and can be extracted. Not requiring the external use of the command prompt would be nice, but as I said above; is this a little too much data to be mixing into my script?

or is the FileWrite($outfile, $infile) the same as cmd -> copy $infile list, $outfilename, whereas its not storing the file data in the array but rather building the file list in the array and instead of using the dos COPY many file to single file, I could use FileWrite, singlefilename, many file list?

Edited by EvilRSA
Link to comment
Share on other sites

or is the FileWrite($outfile, $infile) the same as cmd -> copy $infile list, $outfilename, whereas its not storing the file data in the array but rather building the file list in the array and instead of using the dos COPY many file to single file, I could use FileWrite, singlefilename, many file list?

It is just doing what the copy command would have done. It is taking a list of files, and splicing them together into one bigger file. Each element of the array would contain one filename.

Link to comment
Share on other sites

It is just doing what the copy command would have done. It is taking a list of files, and splicing them together into one bigger file. Each element of the array would contain one filename.

I just did a msgbox on the $infile and it's the whole data of the files, all the Base64 encoded data...can the $infile var hold 80MB's of character data?

Link to comment
Share on other sites

Hi EvilRSA,

just tested with an 80 MiB file. No Problem.

Even doubling the content (with $content &= $content) worked.

Okay - It used around 450MiB of RAM for this, but hey - it worked! :)

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

I just did a msgbox on the $infile and it's the whole data of the files, all the Base64 encoded data...can the $infile var hold 80MB's of character data?

It should handle it. My understanding of your situation is that you have 80MB split into 40 X 2MB files, so you should have no problem.

If you will be using bigger files in the future, you can read smaller chunks of each file instead of the whole file. Just read up on FileRead() in the help file.

Larger chunks or large full files will use more memory. Small chunks or small full files will use less. You will only be holding one file/chunk in memory at a time, not the full spliced file.

Edited by willichan
Link to comment
Share on other sites

I have my compiled script working great, and wanted to take a moment to thank everyone here helping me out in completing my first AutoIT program. I have an awesome niche program that I've been "tinkering" with for several years in Visual Basic.....I think it's time to just scrap that code, and start over in AutoIT, and I'm sure I can finally finish it in a few days! You guys are great! :) :)

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...