Jump to content

Is there a better way to write this?


avery
 Share

Recommended Posts

RunWait(@ComSpec & ' /C ""' & $ins & '7z.exe" e "' & $ins & 'archive.7z" -o"' & $ins & "inf" & '" -pbOCJ7vEiSge02z3A6Tco -y""')

I do FileInstall() on 7z,exe and archive.7z to extract some of the files I'm using with this au3 app I am working on.

I wonder if there is a better way to do things like this so it looks pretty and isn't so easy to typo or hard to modify.

Maybe I'm just to damn tired Zzz.

Thanks if you can help me out. ;-)

www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org
Link to comment
Share on other sites

RunWait(@ComSpec & ' /C ""' & $ins & '7z.exe" e "' & $ins & 'archive.7z" -o"' & $ins & "inf" & '" -pbOCJ7vEiSge02z3A6Tco -y""')

I do FileInstall() on 7z,exe and archive.7z to extract some of the files I'm using with this au3 app I am working on.

I wonder if there is a better way to do things like this so it looks pretty and isn't so easy to typo or hard to modify.

Maybe I'm just to damn tired Zzz.

Thanks if you can help me out. ;-)

Just curious... what's the value of $ins?

What would a finished example of this string look like?

Link to comment
Share on other sites

Just curious... what's the value of $ins?

What would a finished example of this string look like?

Variables:

$ins = "C:\Program Files\NISP_Utilities\"
DirCreate($ins & "inf")
FileInstall("install\7z.exe", $ins)
FileInstall("install\archive.7z", $ins)

Statement:

RunWait(@ComSpec & ' /C ""' & $ins & '7z.exe" e "' & $ins & 'archive.7z" -o"' & $ins & "inf" & '" -pbOCJ7vEiSge02z3A6Tco -y""')

Output:

C:\WINDOWS\system32\cmd.exe /C ""C:\Program Files\NISP_Utilities\7z.exe" e "C:\Program Files\NISP_Utilities\archive.7z" -o"C:\Program Files\NISP_Utilities\inf" -pbOCJ7vEiSge02z3A6Tco -y""

I tried many, many varieties of this Run statement and through process of elimination/trail and error I'm using this one. I've considered just making a batch file and having it RunWait() that instead.

Edited by avery
www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org
Link to comment
Share on other sites

Aren't there some extra quotes in that example?

Either way, you're right, that's a mess.

This is what I came up with my first pass through:

$ins = "C:\Program Files\NISP_Utilities\"

$zip_cmd = $ins & '7z.exe e "' & $ins & 'archive.7z" -o "' & $ins & 'inf" -pbOCJ7vEiSge02z3A6Tco -y'

Msgbox(1,"",$zip_cmd)

;RunWait(@ComSpec &  ' /C "' & $zip_cmd & '"')

MsgBox(1,"",@ComSpec & ' /C "' & $zip_cmd & '"')

Is that generating the correct syntax, a proper string?

It's very similar to what you have. Am not sure if it's any cleaner.

Edited by Spiff59
Link to comment
Share on other sites

Oh, that's sweet, you can hook right into the 7zip DLL instead of going the clunky command-line route.

Me thinks you've fixed the OP right up, BrettF.

Now I might have to think more about throwing together some sort of backup application for around here (something tailored more to my liking than the BackUpMyPC crap thats been running on a schedule here for the last 9 million years). I just bought 2 matching 1TB NAS drives a few months ago (I intend to periodically swap them, keeping one on-site, and one off-site) and I have yet to really take advantage of them. I updated their firmware, cut their capacity in half to 500GB by mirroring them, and now they gather dust. I'd been looking at the Acronis software, but this opens up possibilities...

Link to comment
Share on other sites

Aren't there some extra quotes in that example?

Either way, you're right, that's a mess.

This is what I came up with my first pass through:

$ins = "C:\Program Files\NISP_Utilities\"

$zip_cmd = $ins & '7z.exe e "' & $ins & 'archive.7z" -o "' & $ins & 'inf" -pbOCJ7vEiSge02z3A6Tco -y'

Msgbox(1,"",$zip_cmd)

;RunWait(@ComSpec &  ' /C "' & $zip_cmd & '"')

MsgBox(1,"",@ComSpec & ' /C "' & $zip_cmd & '"')

Is that generating the correct syntax, a proper string?

It's very similar to what you have. Am not sure if it's any cleaner.

cmd.exe output:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

With:

$ins = "C:\Program Files\NISP_Utilities\"
$zip_cmd = $ins & '7z.exe e "' & $ins & 'archive.7z" -o "' & $ins & 'inf" -pbOCJ7vEiSge02z3A6Tco -y'
RunWait(@ComSpec &  ' /k "' & $zip_cmd & '"')
ConsoleWrite(@ComSpec & ' /K "' & $zip_cmd & '"')

ConsoleWrite:

C:\WINDOWS\system32\cmd.exe /K "C:\Program Files\NISP_Utilities\7z.exe e "C:\Program Files\NISP_Utilities\archive.7z" -o "C:\Program Files\NISP_Utilities\inf" -pbOCJ7vEiSge02z3A6Tco -y"

It seems to really like those extra quotes. I got that indication from cmd.exe /?

I do agree yours is cleaner looking to me even though more lines. I think I could add those extra quotes to your example also.

Edited by avery
www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org
Link to comment
Share on other sites

Hi,

Check out this topic by Rasim- it is a 7zip UDF.

http://www.autoitscript.com/forum/index.ph...t=0&start=0

Cheers,

Brett

That is a nice thread full of information ( I just read all 4 pages ). I only need to do one extraction in the very beginning of the script on some very small ASCII files -- nothing to fancy. I may try to just keep my few lines if I can clean them up just a little. Thank you for the great bookmark, great UDF with tons of examples.

www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org
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...