Post-Build Event write to txt

Having trouble running Advanced Installer? Got a bug to report? Post it all here.
Post Reply
GrayFox
Posts: 4
Joined: Wed Jan 23, 2019 9:07 pm

Post-Build Event write to txt

Post by GrayFox » Wed May 08, 2019 10:29 pm

I have a Post-Build Event that should write the [ProductVersion] to a txt file. I have the following parameter set for the event. When I build the event CMD launches but the arguments aren't getting passed. Any thoughts?

Command: cmd.exe
Arguments: echo [|ProductVersion] > C:\inetpub\wwwroot\Builds\version.txt

Catalin
Posts: 1248
Joined: Wed Jun 13, 2018 7:49 am

Re: Post-Build Event write to txt

Post by Catalin » Thu May 09, 2019 7:47 am

Hello,

The "Launch File" custom action is basically a "CreateProcess" function.

This custom action is similar to the run (WIN+R) command from the Windows OS.

For testing purposes, you could try to run the whole command in a run window (simply press WIN+R button). It would look something as it follows:

Code: Select all

cmd.exe echo Something > C:\inetpub\wwwroot\Builds\something.txt
The result will be the same as from within the "Launch File" custom action, the arguments will not be passed to the command prompt.

In order to make this work, we can make use of the following option: "/c". This command will create a process which will run command and then terminate after the command execution is completed. The whole command would look something as it follows:

Code: Select all

cmd.exe /c echo Something > C:\inetpub\wwwroot\Builds\something.txt
Additionally, your custom action should look something as it follows:

File to launch: cmd.exe
Command line: /c echo Something > C:\inetpub\wwwroot\Builds\something.txt


Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

GrayFox
Posts: 4
Joined: Wed Jan 23, 2019 9:07 pm

Re: Post-Build Event write to txt

Post by GrayFox » Thu May 09, 2019 2:44 pm

Thanks! Adding the /c to the argument worked!

Catalin
Posts: 1248
Joined: Wed Jun 13, 2018 7:49 am

Re: Post-Build Event write to txt

Post by Catalin » Fri May 10, 2019 7:33 am

You are always welcome.

Glad I could help.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Post Reply