JeffQOOQAAA Posted February 6, 2017 Posted February 6, 2017 Hi I have a problem , if description not clearly , please bear with me, thanks. As below is my main program. Call(_PoolName) Func _PoolName() Do Local $Poolname = InputBox("Input Machine Pool name", "Format:" &@LF& "Submit Project: Phase_UMA(DIS)_Project" &@LF& "Verfiy Project: Test_Project") If StringRegExp($Poolname, "_UMA_") Then $ID = _ArraySearch($aArray_Base,$Poolname) If $ID = -1 Then _ArrayAdd($aArray_Base, $Poolname) _ArrayDisplay($aArray_Base) Call(_Determine($Poolname)) Else MsgBox(0,"", "Pool name is repeat") Call(_PoolName) EndIf ======================================================================================================================================= Func _Determine($Poolname) $File = FileOpen("auto.txt", 0) Do $Char = FileRead($File, 55000) $Char1 = StringReplace($Char,"$Project_name",$Poolname,0,1) If FileExists(@DesktopDir & "\MachinePool.ps1") Then FileDelete(@DesktopDir & "\MachinePool.ps1") FileWrite(@DesktopDir & "\MachinePool.ps1", $Char1) Else FileWrite(@DesktopDir & "\MachinePool.ps1", $Char1) EndIf Until 1 RunWait(@ComSpec & " /c " & "powershell " & "Set-ExecutionPolicy UnRestricted") $1 = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command " $2 = """. " $3 = "'C:\Users\Administrator\Desktop\MachinePool.ps1'" Run($1 & $2 & $3 &"-auto -playlist C:\Users\Administrator\Desktop\hlk_0113\Playlist.xml", '') EndFunc Function _PoolName() then call another function _Determine($Poolname) but not wait _Determine($Poolname) end then as soon return Function _PoolName() Is possibly?
Subz Posted February 6, 2017 Posted February 6, 2017 One way, in your _Determine.au3 file add the following at the top of your script If $CmdLine[0] > 1 Then _Determine($CmdLineRaw) EndIf Within the _Pool.au3 file replace : Call(_Determine($Poolname)) with Run(@ScriptDir & '\Determine.exe ' & $Poolname, '', @SW_HIDE) Or something like that
JeffQOOQAAA Posted February 6, 2017 Author Posted February 6, 2017 @Subz May i know what is $CmdLine[0]?
Subz Posted February 6, 2017 Posted February 6, 2017 In built variable, basically if you were to run your compiled app "Determine.exe switch1 switch2" it would return $CmdLine[0] = 2 $CmdLine[1] = "switch1" $CmdLine[2] = "switch2" $CmdLineRaw = "switch1 switch2"
JeffQOOQAAA Posted February 6, 2017 Author Posted February 6, 2017 So, for my command switch1 = $Poolname?
Subz Posted February 6, 2017 Posted February 6, 2017 Correct, so as mentioned within the _Pool.au3 file, replace : Call(_Determine($Poolname)) with Run(@ScriptDir & '\Determine.exe ' & $Poolname, '', @SW_HIDE)
JeffQOOQAAA Posted February 6, 2017 Author Posted February 6, 2017 May I built to .exe for Determine.au3?
Subz Posted February 6, 2017 Posted February 6, 2017 Sorry not sure what you mean, do you mean how to compile your script into an exe?
JeffQOOQAAA Posted February 6, 2017 Author Posted February 6, 2017 I want to know , if my parameter only 1 ($Poolname) My $CmdLine is 1?
Subz Posted February 6, 2017 Posted February 6, 2017 Sorry my bad, understand now, the code above should have been: If $CmdLine[0] > 0 Then _Determine($CmdLineRaw) EndIf
careca Posted February 6, 2017 Posted February 6, 2017 (edited) 1 hour ago, JeffQOOQAAA said: I want to know , if my parameter only 1 ($Poolname) My $CmdLine is 1? Your $CmdLine[0] = 1 [0] is the total count and $CmdLine[1] = $Poolname [1] is the first one EDIT: Why call .au3 file when instead of the compiled exe? Edited February 6, 2017 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
JeffQOOQAAA Posted February 7, 2017 Author Posted February 7, 2017 @Subz I've try your way, but seen like no response can't normally execute. Maybe something wrong? If $CmdLine[0] > 0 Then _Determine($CmdLineRaw) EndIf Func _Determine($Poolname) $File = FileOpen("auto.txt", 0) Do $Char = FileRead($File, 55000) $Char1 = StringReplace($Char,"$Project_name",$Poolname,0,1) If FileExists(@DesktopDir & "\MachinePool.ps1") Then FileDelete(@DesktopDir & "\MachinePool.ps1") FileWrite(@DesktopDir & "\MachinePool.ps1", $Char1) Else FileWrite(@DesktopDir & "\MachinePool.ps1", $Char1) EndIf Until 1 RunWait(@ComSpec & " /c " & "powershell " & "Set-ExecutionPolicy UnRestricted") $1 = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command " $2 = """. " $3 = "'C:\Users\Administrator\Desktop\MachinePool.ps1'" Run($1 & $2 & $3 &"-auto -playlist C:\Users\Administrator\Desktop\hlk_0113\Playlist.xml", '') EndFunc ========================================================= Func _PoolName() Do Local $Poolname = InputBox("Input Machine Pool name", "Format:" &@LF& "Submit Project: Phase_UMA(DIS)_Project" &@LF& "Verfiy Project: Test_Project") If StringRegExp($Poolname, "_UMA_") Then $ID = _ArraySearch($aArray_Base,$Poolname) If $ID = -1 Then _ArrayAdd($aArray_Base, $Poolname) _ArrayDisplay($aArray_Base) Run(@ScriptDir & '\Determine.exe ' & $Poolname, '', @SW_HIDE) Else MsgBox(0,"", "Pool name is repeat") Call(_PoolName) EndIf
Subz Posted February 7, 2017 Posted February 7, 2017 Can you compile the following as an .exe and run your PoolName script again, this will create a "Determine.log" file in the same folder and show you the progress and any errors. expandcollapse popupGlobal $bDebug = True If $bDebug Then Global $hOpen = FileOpen(@ScriptDir & '\Determine.log', 1) If $CmdLine[0] > 0 Then If $bDebug Then _DebugLog('$CmdLineRaw = ' & $CmdLineRaw) _Determine($CmdLineRaw) EndIf FileClose($hOpen) Func _DebugLog($sString) FileWrite($hOpen, @YEAR & '\' & @MON & '\' & @MDAY & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & ' :: ' & $sString & @CRLF) EndFunc Func _Determine($Poolname) If $bDebug Then _DebugLog('_Determine(' & $Poolname & ')') $File = FileOpen("auto.txt", 0) If $bDebug Then _DebugLog('FileOpen("auto.txt", 0) Returned :' & @error) Do $Char = FileRead($File, 55000) If $bDebug Then _DebugLog('$Char Returned :' & $Char) $Char1 = StringReplace($Char,"$Project_name",$Poolname,0,1) If $bDebug Then _DebugLog('$Char1 Returned :' & $Char1) If FileExists(@DesktopDir & "\MachinePool.ps1") Then If $bDebug Then _DebugLog('FileExists :"' & @DesktopDir & '\MachinePool.ps1"') $hFileDelete = FileDelete(@DesktopDir & "\MachinePool.ps1") If $bDebug Then _DebugLog('FileDelete :"' & @DesktopDir & '\MachinePool.ps1" Returned - ' & $hFileDelete) $hFileWrite = FileWrite(@DesktopDir & '\MachinePool.ps1', $Char1) If $bDebug Then _DebugLog('FileWrite :"' & @DesktopDir & '\MachinePool.ps1" Returned - ' & $hFileWrite) Else $hFileWrite = FileWrite(@DesktopDir & '\MachinePool.ps1', $Char1) If $bDebug Then _DebugLog('FileWrite :"' & @DesktopDir & '\MachinePool.ps1" Returned - ' & $hFileWrite) EndIf Until 1 $hRunWait = RunWait(@ComSpec & " /c " & "powershell " & "Set-ExecutionPolicy UnRestricted") If $bDebug Then _DebugLog('RunWait : "' &@ComSpec & ' /c powershell Set-ExecutionPolicy UnRestricted" Returned - ' & $hRunWait) $1 = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command " $2 = """. " $3 = "'C:\Users\Administrator\Desktop\MachinePool.ps1'" $hRun = Run($1 & $2 & $3 &"-auto -playlist C:\Users\Administrator\Desktop\hlk_0113\Playlist.xml", '') If $bDebug Then _DebugLog('Run : "' & $1 & $2 & $3 & '"-auto -playlist "C:\Users\Administrator\Desktop\hlk_0113\Playlist.xml" Returned - ' & $hRun) EndFunc
JeffQOOQAAA Posted February 7, 2017 Author Posted February 7, 2017 @Subz Sorry my bad, It can normally execute, but one thing need you help Is possibly when call determine.exe then main program can as soon as return poolname function? I don't want to wait determin.exe end then return poolname function.....
Subz Posted February 7, 2017 Posted February 7, 2017 Unfortunately you have only posted a portion of your _PoolName() function, but here is how I would do it: nb: Just added Ctrl+q to exit the function HotKeySet('^q', 'ExitScript') $aArray_Base[1] While 1 _PoolName() Sleep(100) WEnd Func _PoolName() Local $Poolname = InputBox("Input Machine Pool name", "Format:" &@LF& "Submit Project: Phase_UMA(DIS)_Project" &@LF& "Verfiy Project: Test_Project") If StringRegExp($Poolname, "_UMA_") Then $ID = _ArraySearch($aArray_Base,$Poolname) If $ID = -1 Then _ArrayAdd($aArray_Base, $Poolname) Run(@ScriptDir & '\Determine.exe ' & $Poolname, '', @SW_HIDE) Return EndIf EndIf EndFunc Func ExitScript() Exit EndFunc
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