MuffettsMan Posted April 17, 2015 Posted April 17, 2015 (edited) attempting to call a command line zip utility ( http://stahlworks.com/dev/zip.exe) via the Run() command and not getting any output - for sanity sake i spit out the command to the console and copy paste that into the command prompt in the script dir and it runs just fine any ideas? $source = "D:\-= Audio Books =-\WoT\11 - Knife of Dreams\AlbumArtSmall.jpg" $destZip = @ScriptDir & "\tmp\2m5.zip" ; RAR can't zip on the command line >_< use zip.exe instead..... ; zip.exe -r mydir.zip mydir ; data\zip\zip.exe -r tmp\output.zip "D:\-= Audio Books =-\WoT\11 - Knife of Dreams\AlbumArtSmall.jpg" $runCmd = 'data\Zip\zip.exe -r "' & $destZip & '" "' & $source & '"' ConsoleWrite("$runCmd: " & $runCmd & @CRLF) Local $iPID = Run(@ComSpec & 'data\Zip\zip.exe -r "' & $destZip & '" "' & $source & '"', @ScriptDir, @SW_HIDE, $STDOUT_CHILD) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. ; Local $sOutput = StdoutRead($iPID) ; ConsoleWrite($sOutput) ConsoleWriteGUI("Stdout Read START:" & @CRLF) While 1 $sOutput = StdoutRead($iPID) If @error Then ; Exit the loop if the process closes or StdoutRead returns an error. ExitLoop EndIf ConsoleWriteGUI($sOutput) WEnd ConsoleWriteGUI("Stdout Read COMPLETED." & @CRLF) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) Console Output: $runCmd: dataZipzip.exe -r "D:scriptsrift_fisherccdtmp2m5.zip" "D:-= Audio Books =-WoT11 - Knife of DreamsAlbumArtSmall.jpg" Stdout Read START: Stdout Read COMPLETED. (in which when i call rar.exe i do get results in standard out.... and if i copy the runCmd output and paste to the command line it makes the zip just fine Cmd Line Output: D:scriptsrift_fisherccd>dataZipzip.exe -r "D:scriptsrift_fisherccdtmpmanual.zip" "D:-= Audio Books =-WoT11 - Knife of DreamsAlbumArtSmall.jpg" adding: -= Audio Books =-/WoT/11 - Knife of Dreams/AlbumArtSmall.jpg (160 bytes security) (deflated 3%) (so i'd expect to be getting that adding line in stout) Edited April 17, 2015 by MuffettsMan Don't let that status fool you, I am no advanced memeber!
ViciousXUSMC Posted April 17, 2015 Posted April 17, 2015 Not 100% sure but I think the /c or /k is required right after @ComspecI have gotten to the point where I just FileInstal() and ShellExecute() a .bat file with my commands unless its a very simple command because I often have a lot of issues with spaces and quotes.
Solution BrewManNH Posted April 17, 2015 Solution Posted April 17, 2015 Use this command until you know it's working. After you can verify that it's working, you can change the /k to /c so that the command window will close after it's finished running. Then you can also change the @SW_SHOW to @SW_HIDE to keep the window hidden. Before you KNOW it's working do NOT use /c or @SW_HIDE. How are you ever going to know what the problem is if you're hiding all the error messages from yourself? Run(@ComSpec & ' /k data\Zip\zip.exe -r "' & $destZip & '" "' & $source & '"', @ScriptDir, @SW_SHOW, $STDOUT_CHILD) If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now