le15 Posted November 17, 2006 Share Posted November 17, 2006 How to run an exe with parameter ? expandcollapse popup#Include <Array.au3> ;================================================================================================================================ Dim $Array__FolderList [1] Dim $Array__EmptyFolder [1] Dim $Array__FolderName [1] Dim $Array__SystemFolder [1] Dim $Array__TargetFolder [1] $WBzip = @ScriptDir & "\WBzip.exe" $ScriptName = FileOpen(@ScriptDir & "\Test.script", 2) _FolderList ("E:\WB_Source\Applications\IrfanView") _EmptyFolder($Array__FolderList) _FolderName($Array__FolderList) _SystemFolder($Array__FolderList) _TargetFolder($Array__FolderList) ;_arrayDisplay ($Array__FolderList,"Folders") ;_arrayDisplay ($Array__EmptyFolder,"EmptyFolder") ;_arrayDisplay ($Array__FolderName,"FolderName") ;_arrayDisplay ($Array__SystemFolder,"SystemFolder") ;_arrayDisplay ($Array__TargetFolder,"TargetFolder") ;-------------------------------------------------------------------------------------------------------------------------------- $CountFolder = $Array__FolderList[0] For $i = 1 To $CountFolder If $Array__EmptyFolder[$i] = 1 Then ContinueLoop Else Dim $Array__FileList [1] _FileList($Array__FolderList[$i]) For $j = 1 To $Array__FileList[0] Run($WBzip & " /a " & $ScriptName & " " & $Array__FolderName[$i] & " " & $Array__FileList[$j]) Next EndIf Next Link to comment Share on other sites More sharing options...
PaulIA Posted November 17, 2006 Share Posted November 17, 2006 (edited) Search the forum... Edited November 17, 2006 by PaulIA Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
sheck Posted November 17, 2006 Share Posted November 17, 2006 How to run an exe with parameter ?Can you explain what excatly you are trying to run and r u just trying to run executable with parameters or trying to pass parameters to another app ? Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
le15 Posted November 18, 2006 Author Share Posted November 18, 2006 Can you explain what excatly you are trying to run and r u just trying to run executable with parameters or trying to pass parameters to another app ?Trying to pass parameters to another app from my au3 Run("WBzip.exe" & " -a " & "Test.Script" & " " & $Array__FolderName[$i] & " " & $Array__FileList[$j]) But that don't work Link to comment Share on other sites More sharing options...
sheck Posted November 18, 2006 Share Posted November 18, 2006 Trying to pass parameters to another app from my au3 Run("WBzip.exe" & " -a " & "Test.Script" & " " & $Array__FolderName[$i] & " " & $Array__FileList[$j]) But that don't work The commad seems to be OK. What kind of error r u getting, please post everything you're doing and all erors you're getting. It's hard to say what's going on, expecially with external executable. Check that parameters are set correctly. Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
le15 Posted November 18, 2006 Author Share Posted November 18, 2006 The commad seems to be OK. What kind of error r u getting, please post everything you're doing and all erors you're getting. It's hard to say what's going on, expecially with external executable. Check that parameters are set correctly.The file is not write All code here and WBzip in attachementexpandcollapse popup#Include <Array.au3> ;================================================================================================================================ Dim $Array__FolderList [1] Dim $Array__EmptyFolder [1] Dim $Array__FolderName [1] Dim $Array__SystemFolder [1] Dim $Array__TargetFolder [1] $WBzip = @ScriptDir & "\WBzip.exe" $ScriptName = @ScriptDir & "\Test.script" FileOpen($ScriptName,2) _FolderList ("E:\WB_Source\Applications\IrfanView") _EmptyFolder($Array__FolderList) _FolderName($Array__FolderList) _SystemFolder($Array__FolderList) _TargetFolder($Array__FolderList) ;_arrayDisplay ($Array__FolderList,"Folders") ;_arrayDisplay ($Array__EmptyFolder,"EmptyFolder") ;_arrayDisplay ($Array__FolderName,"FolderName") ;_arrayDisplay ($Array__SystemFolder,"SystemFolder") ;_arrayDisplay ($Array__TargetFolder,"TargetFolder") ;-------------------------------------------------------------------------------------------------------------------------------- $CountFolder = $Array__FolderList[0] For $i = 1 To $CountFolder If $Array__EmptyFolder[$i] = 1 Then ContinueLoop Else Dim $Array__FileList [1] _FileList($Array__FolderList[$i]) For $j = 1 To $Array__FileList[0] $WBzip_Cmd = $WBzip & " -a " & $ScriptName & " " & $Array__FolderName[$i] & " " & $Array__FileList[$j] RunWait($WBzip & " -a " & $ScriptName & " " & $Array__FolderName[$i] & " " & $Array__FileList[$j]) MsgBox(0,"Info",$WBzip_Cmd) Next EndIf Next ;================================================================================================================================ Func _FileList($current) ;-------------------------------------------------------------------------------------------------------------------------------- Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then $Array__FileList[0] = ($Array__FileList[0] + 1) _ArrayAdd ($Array__FileList, $current & "\" & $file) EndIf WEnd FileClose($search) EndFunc ;================================================================================================================================ Func _FolderList($current) ;-------------------------------------------------------------------------------------------------------------------------------- _arrayAdd ($Array__FolderList,$current ) _ListFolder($current) $Array__FolderList[0] = ($Array__FolderList[0] + 1) Return $Array__FolderList EndFunc ;================================================================================================================================ Func _ListFolder($current) ;-------------------------------------------------------------------------------------------------------------------------------- Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop ;~ If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then ;~ ;~ $FileList[0] = ($FileList[0] + 1) ;~ _ArrayAdd ($Array__FileList, $current & "\" & $file) ;~ ;~ ;~ EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then $Array__FolderList[0] = ($Array__FolderList[0] + 1) _arrayAdd ($Array__FolderList,$current & "\" & $file) _ListFolder($current & "\" & $file) EndIf WEnd FileClose($search) Return $Array__FolderList EndFunc ;================================================================================================================================ Func _EmptyFolder($av_Array) ;-------------------------------------------------------------------------------------------------------------------------------- Local $iCurrentPos, $iUBound If Not IsArray($av_Array) Then SetError(1) Return -1 EndIf $i_UBound = UBound($av_Array) - 1 For $i = 1 To $i_UBound ;----------------------------------- $size = DirGetSize($av_Array[$i] , 2) If $size Then _arrayAdd ($Array__EmptyFolder, "0") Else _arrayAdd ($Array__EmptyFolder, "1") EndIf ;----------------------------------- Next Return $Array__EmptyFolder EndFunc ;================================================================================================================================ Func _FolderName($av_Array) ;-------------------------------------------------------------------------------------------------------------------------------- Local $iCurrentPos, $iUBound, $iLocation, $iStartFolder If Not IsArray($av_Array) Then SetError(1) Return -1 EndIf $i_UBound = UBound($av_Array) - 1 For $i = 1 To $i_UBound ;----------------------------------- $ilocation = StringInStr ( $av_Array[$i] , "\", 0, - 1 ) $iStartFolder = StringTrimLeft($av_Array[$i], $ilocation) IF StringInStr ( $av_Array[$i], "\TO_" , 0, - 1 ) > 0 Then IF StringLeft($iStartFolder,3) = "TO_" Then _arrayAdd ($Array__FolderName, $iStartFolder) Else _arrayAdd ($Array__FolderName, "To_" & $iStartFolder) EndIf Else _arrayAdd ($Array__FolderName, $iStartFolder) EndIf ;----------------------------------- Next Return $Array__FolderName EndFunc ;================================================================================================================================ Func _SystemFolder($av_Array) ;-------------------------------------------------------------------------------------------------------------------------------- Local $iCurrentPos, $iUBound, $ilen, $iLenFolder If Not IsArray($av_Array) Then SetError(1) Return -1 EndIf $i_UBound = UBound($av_Array) - 1 For $i = 1 To $i_UBound ;----------------------------------- $ilen = StringLen($av_Array[1]) - 1 $iLenFolder = StringTrimLeft( $av_Array[$i], $ilen) IF StringInStr ( $av_Array[$i], "\TO_" , 0, - 1 ) > 0 Then _ArrayAdd ($Array__SystemFolder, "1") Else _arrayAdd ($Array__SystemFolder, "0") EndIf ;----------------------------------- Next Return $Array__SystemFolder EndFunc ;================================================================================================================================ Func _TargetFolder($av_Array) ;-------------------------------------------------------------------------------------------------------------------------------- Local $iCurrentPos, $iUBound, $ilen, $iLenFolder If Not IsArray($av_Array) Then SetError(1) Return -1 EndIf $i_UBound = UBound($av_Array) - 1 For $i = 1 To $i_UBound ;----------------------------------- $ilen = StringLen($av_Array[1]) +1 $iLenFolder = StringTrimLeft( $av_Array[$i], $ilen) IF StringInStr ( $av_Array[$i], "\TO_" , 0, -1 ) > 0 Then _ArrayAdd ($Array__TargetFolder, StringTrimLeft($iLenFolder,3 )) Else _ArrayAdd ($Array__TargetFolder, $iLenFolder) EndIf ;----------------------------------- Next Return $Array__TargetFolder EndFunc ;================================================================================================================================ Link to comment Share on other sites More sharing options...
sheck Posted November 18, 2006 Share Posted November 18, 2006 RunWait($WBzip & " -a " & $ScriptName & " " & $Array__FolderName[$i]& " " & $Array__FileList[$j])It doesn't seem that any of your functions return the value for $Array__FileList[$j]. Your first function seems to calculate it, but doesn't return anything. AutoIt will return 0 for any user defined function that doesn't have a Return value specified. Also in your third function u call the same function from inside itself; not sure why u need that if you have a loop there. Func _ListFolder($current) Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then $Array__FolderList[0] = ($Array__FolderList[0] + 1) _arrayAdd ($Array__FolderList,$current & "\" & $file) ????? -----> _ListFolder($current & "\" & $file) EndIf WEnd FileClose($search) Return $Array__FolderList EndFunc Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
le15 Posted November 18, 2006 Author Share Posted November 18, 2006 It doesn't seem that any of your functions return the value for $Array__FileList[$j]. Your first function seems to calculate it, but doesn't return anything. AutoIt will return 0 for any user defined function that doesn't have a Return value specified. Also in your third function u call the same function from inside itself; not sure why u need that if you have a loop there. Func _ListFolder($current) Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then $Array__FolderList[0] = ($Array__FolderList[0] + 1) _arrayAdd ($Array__FolderList,$current & "\" & $file) ????? -----> _ListFolder($current & "\" & $file) EndIf WEnd FileClose($search) Return $Array__FolderList EndFuncNo all are good _FolderList ("E:\WB_Source\Applications\IrfanView") <------ Here you select a valid folder _EmptyFolder($Array__FolderList) _FolderName($Array__FolderList) _SystemFolder($Array__FolderList) _TargetFolder($Array__FolderList) ;_arrayDisplay ($Array__FolderList,"Folders") ---------- ;_arrayDisplay ($Array__EmptyFolder,"EmptyFolder") ;_arrayDisplay ($Array__FolderName,"FolderName") Test with that ;_arrayDisplay ($Array__SystemFolder,"SystemFolder") ;_arrayDisplay ($Array__TargetFolder,"TargetFolder") ---------- ????? -----> _ListFolder($current & "\" & $file) -----> This is for scan sub folder Link to comment Share on other sites More sharing options...
le15 Posted November 18, 2006 Author Share Posted November 18, 2006 How to make this work ? I want to run "WBzip.exe" with 4 params $WBzip = @ScriptDir & "\WBzip.exe" $ScriptName = @ScriptDir & "\Test.script" $Section = "Test" $FileName = @ScriptDir & "\MksConvert.exe" FileOpen($ScriptName,2) RunWait($WBzip & " -a " & $ScriptName & " " & $Section & " " & $FileName) Link to comment Share on other sites More sharing options...
Developers Jos Posted November 18, 2006 Developers Share Posted November 18, 2006 How to make this work ? I want to run "WBzip.exe" with 4 params $WBzip = @ScriptDir & "\WBzip.exe" $ScriptName = @ScriptDir & "\Test.script" $Section = "Test" $FileName = @ScriptDir & "\MksConvert.exe" FileOpen($ScriptName,2) RunWait($WBzip & " -a " & $ScriptName & " " & $Section & " " & $FileName) oÝ÷ Ûú®¢×¢,¢K§ë,ʧyçm :.nWº^Ê«¥ªÚë^®Æ®¶se'VåvBb33²gV÷C²b33²fײb33cµt'¦fײb33²gV÷C²ÖgV÷C²b33²fײb33cµ67&DæÖRfײb33²gV÷C²gV÷C²b33²fײb33cµ6V7Föâfײb33²gV÷C²gV÷C²b33²fײb33c´fÆTæÖRfײb33²gV÷C²b33² SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
le15 Posted November 18, 2006 Author Share Posted November 18, 2006 Looks ok unless you need to DoubleQuote your parameters... RunWait('"' & $WBzip & '" -a "' & $ScriptName & '" "' & $Section & '" "' & $FileName & '"') Thank you Link to comment Share on other sites More sharing options...
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