Jump to content

Call another au3 then return main program


Recommended Posts

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?

Link to comment
Share on other sites

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 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

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

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.

Global $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

 

Link to comment
Share on other sites

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

 

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...