ur

How to log info with Installshield

16 posts in this topic

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

Share this post


Link to post
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.

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
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....

Share this post


Link to post
Share on other sites

My pleasure @ur :thumbsup:


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
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.

Share this post


Link to post
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.

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

But I didn't get documentation there.Generally where can I check any existing UDF repositories and its use and documentation?

Edited by ur

Share this post


Link to post
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


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

That was a very quick adoption of my code @ur :D.

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

Thanks Dcoder :)

Share this post


Link to post
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

  • Similar Content

    • lewisg
      By lewisg
      Suddenly a RunWait command has stop working after 2 years of no errors, issues, or problems. The code uses RunWait to start Plink.exe, a command-line remote connection tool similar to UNIX ssh. I'm using it to ssh to a linux (Centos) machine, run a Perl script, and redirect the output to a file on a PC running the AutoIt script.  
       
      $FilePath = "C:\AutoIT\LED" $FilePathPlus = $FilePath & "\plink.exe" $Code1 = RunWait(@ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt ", @SW_SHOW) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " = ' & @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console The ConsoleWrite output when cut-n-pasted into a DOS box produces the expected file so I know it works. I've also tried many variations of the function moving, adding, and changing the " and ' (quote) marks. Also tried it without the @ComSpec macro and other related functions...e.g.  ShellExecuteWait , etc.
      The PC is a Windows 10 64bit and AutoIT is version 3.3.14.2.
      Searching here and Google has not yielded any clues that helped. 
    • rkr
      By rkr
      Hi, I have a software which has a 'run file'-ie; when i double click on that file, the input file of the software is run by the software. I wish to double click/execute this run file using autoit. how do i achieve this. i opened the software and it shows the input file and run file in same folder, i will put my autoitscript file too in same location. how do i simulate double clicking the run file (using its file name, say - abc.run ). I entered the following lines to make software window active - it became active, dont know how to go forward
      Winactivate("program title")
      winwaitactivate("program title")
      controlclick("program title","abc.run",1000,"primary",2) ; 1000 is ctrl id
    • goodmanjl531
      By goodmanjl531
      Hope someone can help as quotes within quotes is always confusing.  I am creating a silent install of printer software and want to call via runwait comspec line.
      The call within a cmd line is below
      samsung.exe /s /n"Samsung SL-M3220ND" /p"xxx"
      xxx will be stored as a variable  $PrinterIP which would be as example  10.10.10.20    I need to use a variable as i am doign this for a business and need it to be based on the store i install at that has a specific IP range.
       
      I started with the below as 2 possibilities but no luck..
      RunWait(@ComSpec & "/c " & "samsung.exe /s /n""Samsung SL-M3220ND"" /p""" & $PrinterIP ") RunWait(@ComSpec & "/c " & "samsung.exe /s /n'Samsung SL-M3220ND' /p'" & $PrinterIP '") but i cant get it to compile as i have errors on the line..  thanks in advance.
    • tremolux66
      By tremolux66
      Initial Problem
      I've written several scripts with the following sequence:
      Execute a program using Run w/stdout+stderr captured Typically processes all the files in one directory tree to populate a second tree Execute a second program (also with Run) to monitor the products of the first program and Display a progress bar (percentage of output files complete) Also monitor the first program's process and exit when it terminates The script then calls ProcessWaitClose (no timeout) on the first program's process and Checks the first program's results Kills the monitor program if it hasn't already exited on its own. Sometimes, ProcessWaitClose returns 1 with @error = 0 and @extended = 0xCCCCCCCC (actually, 0xFFFFFFFFCCCCCCCC), which seems ambiguous: the documentation says that @error = non-zero and @extended = 0xCC... means an invalid PID (unclear what the return value is), and 1 is returned for non-existent processes (but no mention of @extended). The 1/0/0xCC... result seems to occur when the first program exits very quickly (with or without an error). Since the exit value is not available, the script scans the program's output and tries to determine whether it ran successfully. This has gotten complicated and unreliable.
      Partial Fix
      I've now implemented a much simpler approach that works for most cases:
      Modify the monitor program so that it ignores the other program's process (the monitor always gets killed by the script anyway) Execute the monitor program first using Run, then execute the processing program with RunWait When RunWait returns, the child process exit value is available, so the script can ignore its output (which isn't available anyway) If the monitor program is still running, kill it. Remaining Issue
      However, there are still a couple of cases where it's necessary to get both the exit value from the processing program and its output. Since RunWait doesn't capture stdout and stderr for the parent script, it's looking like I'll have to call RunWait and redirect the 2 streams to a temp file and then scan it. Also, to do the redirect, I think I'll have to use @ComSpec to execute the processing program, which adds an undesired layer.
      Does anybody have a better (cleaner) way to handle these cases?