Jump to content

How to log info with Installshield


ur
 Share

Recommended Posts

I have written a script to build the Installshield project file(.ism) to setup files(.msi or .exe based on the release settings..).

So when the user runs the script the process will be automatic for multiple ism files.

Func Build($sOutputIsm,$ReleaseName,$sFilePath="None",$NewName="None")  ;build the ism to get the msi

    If not FileExists($sOutputIsm) Then
        Logging("File Not Found: $sOutputIsm$",4)
        MsgBox($MB_OK + $MB_ICONERROR, "Error", "Could not find file ""$sOutputIsm$"".")
        Return
    EndIf
    Logging("Started Building $sOutputIsm$",4)
    ShowTrayTip($AppName, "Started Building $sOutputIsm$", 10, $TIP_ICONASTERISK)
    Dim $sBuildExe,$sBuildCommand,$Ret
    $sBuildExe = FindFileInPath("ISCmdBld.exe", "%ProgramFiles(x86)%\InstallShield")
    $sBuildCommand = """$sBuildExe$"" -p ""$sOutputIsm$"" -r ""$ReleaseName$"" -s"
    ;MsgBox(0,"",$sBuildCommand)
    $Ret = RunWait($sBuildCommand)
    If $Ret <> 0 Then
        ShowTrayTip($AppName,"ISM Build Failed, Please build the ISM Manually.",10, $TIP_ICONHAND)
        MsgBox($MB_OK + $MB_ICONERROR, "Error", "Could not build ""$sOutputIsm$"". Please build manually.")
        Logging("Error $Ret$ while Building $sOutputIsm$",4)
        Return;Exit(1)
    Else
        ShowTrayTip($AppName,"ISM Build Completed",10, $TIP_ICONASTERISK)
        Logging("Completed Building $sOutputIsm$",4)
        if not StringCompare($NewName, "None")=0 then MoveEXE($sFilePath,$NewName)
    EndIf
EndFunc

The problem is when we run the ISCmdBuild.exe the RunWait will give whether fail or success but not what are the errors we got.
If we use Run, it will give that logging but we don't have the feature of getting fail/success as RunWait.

If we run the above code by removing -s and using redirection operator > to a file, it is running manually but failing with autoit.

Like
 

$sBuildCommand = """$sBuildExe$"" -p ""$sOutputIsm$"" -r ""$ReleaseName$"" > c:\logs\uday.log"

Any help on this??

 

And also, in some machines the installshield shortcut is launching fine as licensed version but with ISCmdBld.exe it is giving error as licensing info missing or not registered.

 

Any suggestion on this too??

Link to comment
Share on other sites

If you want to capture both the Exit Code and the Console Output, you would have to do some tricky things. Luckily I have made a UDF for that ;), Try my Process UDF :D.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

3 hours ago, TheDcoder said:

If you want to capture both the Exit Code and the Console Output, you would have to do some tricky things. Luckily I have made a UDF for that ;), Try my Process UDF :D.

Thank you very much TheDcoder....

Link to comment
Share on other sites

22 minutes ago, TheDcoder said:

My pleasure @ur :thumbsup:

Any suggestion for the second issue mentioned too.

In some machines the installshield shortcut is launching fine as licensed version but with ISCmdBld.exe it is giving error as licensing info missing or not registered.

Link to comment
Share on other sites

31 minutes ago, ur said:

In some machines the installshield shortcut is launching fine as licensed version but with ISCmdBld.exe it is giving error as licensing info missing or not registered.

Hmm... I can't help you with such issue as I don't use InstallShield. Try contacting InstallShield support regarding this issue.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

  • 1 month later...

Hi @TheDcoder

I have been using the method mentioned by you to log the info and also to track the error code.It is working fine.

 

But it is logging the output at the end of the process execution.

Whereas now a days, the installshield building is taking around 2 hours and even more and it is failing at the end.

Could you please suggest anything so that it would write the log data since the start of process instead of making it available only at the end.As the command line output of installshield is available form the execution start itself.

Link to comment
Share on other sites

On 26/9/2016 at 4:22 PM, ur said:

Could you please suggest anything so that it would write the log data since the start of process instead of making it available only at the end.As the command line output of installshield is available form the execution start itself.

There are 2 ways you can use my UDF. The 1st is the simplest which returns the Exit Code + Output at the end, The 2nd one is more hard to do but with it you will be able to get the output from the start of the process!

The 2nd method is demonstrated in the example script, its the part where you see live output from tracert google.com :), you can study the code and check the documentation for more information :D.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

4 hours ago, ur said:

Generally where can I check any existing UDF repositories and its use and documentation?

There is no repository for UDFs, you have to just download the .au3 scripts from the web and read them in SciTE, that's the only way :D

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

1 hour ago, TheDcoder said:

There is no repository for UDFs, you have to just download the .au3 scripts from the web and read them in SciTE, that's the only way :D

That's the normal case, just reading function headers. Best case are demostrated by:

and i'm sure there are some more well documented udfs available.

Link to comment
Share on other sites

  • 2 months later...
On 9/28/2016 at 2:27 PM, TheDcoder said:

There are 2 ways you can use my UDF. The 1st is the simplest which returns the Exit Code + Output at the end, The 2nd one is more hard to do but with it you will be able to get the output from the start of the process!

The 2nd method is demonstrated in the example script, its the part where you see live output from tracert google.com :), you can study the code and check the documentation for more information :D.

The second method is displaying the output on a window.

Is there any way to redirect the output to a file during the execution instead of end of execution.

Link to comment
Share on other sites

6 hours ago, ur said:

Is there any way to redirect the output to a file during the execution instead of end of execution.

Yes, just look at my code which redirects the output to the GUI. This part (highlighted) is what you need to study and understand ;).

Edited by TheDcoder

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Yeah got that...thanks TheDcoder.

Added this function in the UDF file for this purpose.

 

Func Logging($sMessage,$sLogFile=@TempDir&"\Logging_Runtime.log")
    FileWrite($sLogFile,$sMessage&@CRLF)
EndFunc

Func _Process_DebugLogRunCommand($hProcessHandle, $iPID)

    Local $sOutput = "", $sPartialOutput = "" ; Declare the output variable
    While ProcessExists($iPID) ; Loop until the process finishes
        $sPartialOutput = StdoutRead($iPID) ; Record the output
        ;$sOutput &= $sPartialOutput
        Logging($sPartialOutput)
        Sleep(1000) ; Don't kill the CPU
    WEnd
    $sPartialOutput = StdoutRead($iPID) ; Record the output
    Logging($sPartialOutput)
    ;$sOutput &= $sPartialOutput
    Local $iExitCode = _Process_GetExitCode($hProcessHandle)
    Logging(@CRLF & @CRLF & "Debug Complete! The Exit Code was: " & $iExitCode) ; Display the exit code
    Return $iExitCode
    ;Return SetExtended($iExitCode, $sOutput) ; Return True
EndFunc

 

Link to comment
Share on other sites

  • 2 weeks later...

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

×
×
  • Create New...