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

#16 ·  Posted

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

    • BlazerV60
      By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
      Brian
    • breakbadsp
      By breakbadsp
      I want to run a python script from autoit. 
      I know we can do this with shellexecute or run , but this python script takes 3 cmd line arguments.
      How to pass them from autoit script?
      I tried many ways.
      Following solution also not working 
      e.g. 
      RunWait( 'fullpath\Python.exe Scriptpath\ReadLog.py  -f "file.log" -k "key" -e "errMsg" ') Found solution:
      RunWait( 'fullpath\Python.exe ReadLog.py -f "file.log" -k "key" -e "errMsg" ', 'Working_directory_path')  
      PFB description:
      https://stackoverflow.com/questions/45757834/how-to-pass-command-line-arguments-to-a-python-script-anyscript-while-executin
       
    • rootx
      By rootx
      I need help to understand why the run function does not work, but if i use it directly inside cmd shell the command works. $where is the name of the jpg file
      ShellExecute(@ComSpec ," /k C:\Users\root\Desktop\test\exiftool.exe -p $FileName "&'"'&$where&'"'&" > "&'"'&@ScriptDir&"\out.txt"&'"',@ScriptDir);<----- work Run("C:\Users\root\Desktop\test\exiftool.exe -p $FileName "&$where&" > "&@ScriptDir&"\out.txt",@ScriptDir);<--- doesn't work I would use the run command!
      Thx
    • nacerbaaziz
      By nacerbaaziz
      Hello
      How are you
      I have a question, please.
      I've created a window and i need
      when i run the script if it detect an other copy from the same script was runing
       the script close the first copy Automatically and run a new copy
      I want an example to understand it
    • kawliga751
      By kawliga751
      I am attempting to run an Autoit.exe with schtasks every weekday @ 9:05 am.
      I have the below
      C:\>SchTasks /Create /TN "P10Run" /TR "O:\AUTOIT\P40 Run.au3" /SC WEEKLY /D MON, TUE,WED,THU,FRI /ST 09:05:00 SUCCESS: The scheduled task "P10Run" has successfully been created. I also did a "test" run :
      C:\>Schtasks /Run /TN "P10Run SUCCESS: Attempted to run the scheduled task "P10Run". But when I run my query to verify success my "Last Result" seems to indicate that the script did not run:
      C:\>SCHTASKS /QUERY /FO LIST /V /TN "P10RUN" Folder: \ HostName: xxxxxxxxxxxxxxxx TaskName: \P10RUN Next Run Time: N/A Status: Could not start Logon Mode: Interactive only Last Run Time: 6/14/2017 9:08:56 AM Last Result: -2147024894 Author: xxxxxxx Task To Run: O:\AUTOIT\P40 Run.au3 Start In: N/A Comment: N/A Scheduled Task State: Enabled Idle Time: Disabled Power Management: Stop On Battery Mode, No Start On Batterie s Run As User: xxxxxxxxx\xxxxxxxx Delete Task If Not Rescheduled: Enabled Stop Task If Runs X Hours and X Mins: 72:00:00 Schedule: Scheduling data is not available in this f ormat. Schedule Type: Weekly Start Time: 9:05:00 AM Start Date: 6/14/2017 End Date: N/A Days: MON, TUE, WED, THU, FRI Months: Every 1 week(s) Repeat: Every: Disabled Repeat: Until: Time: Disabled Repeat: Until: Duration: Disabled Repeat: Stop If Still Running: Disabled C:\> Is there something missing in my command? Also is there a better way to make sure that the script does in fact sun successfully?
      Thanks In Advance!