sfaust
Posts: 48
Joined: Tue Oct 13, 2015 11:57 pm

Date in installer name?

Is there a way to put the current date in an msi name? I would ideally like something like:

My Product 1.0 Setup 2015-10-13.msi

It's not a huge deal to change it after build but it would save me a step if I could make it automatic. I see that msi name can have variables but I don't see one for date. I also thought of trying a build event but don't see an easy way to do it that way either (I see file rename but I would have to hard code the file paths, would be nice if they were variables). Anyway I'm still new to advanced installer so sorry if these are very basic questions...
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Date in installer name?

Hello and welcome to Advanced Installer forums,

In order to implement your scenario, you may need to create your own vbscript or batch file with this functionality.
Please take a look on the Need to the installation filename include creation datetime forum thread which debates a similar subject.

A piece of code with this functionality is the following:

Code: Select all

Set fso = CreateObject("Scripting.FileSystemObject")
​
set oFldr = fso.getfolder("D:\")
​
Dim myString
myString = FormatDateTime(Now(),vbLongDate) & " " & Hour(Now())& "." & Minute(Now()) & "." & Second(Now()) & ".txt"
​
msgbox(myString)
​
for each ofile in oFldr.Files
if lcase(ofile.Name = "old file.txt") then
     ofile.Name = myString
   end if
Next
Should there be any difficulty you encounter implementing something, please do not hesitate to contact me and I will gladly assist.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
sfaust
Posts: 48
Joined: Tue Oct 13, 2015 11:57 pm

Re: Date in installer name?

Thank you very much, I will give that a try.
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Date in installer name?

You're welcome,

Should there be any difficulty you encounter implementing something, please do not hesitate to contact me and I will gladly assist.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
AaronZhang
Posts: 1
Joined: Mon Jul 01, 2019 5:16 am

Re: Date in installer name?

here is my solution.

1. "rename_msiname_with_date.bat"
::Rename AppName_3.0.3.8739_Win64.msi ToAppName_20190701_3.0.3.8739_Win64.msi
chcp 65001
set MsiName=AppName_%1_Win64.msi
set MsiNameWithDate=AppName_%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%_%1_Win64.msi
ren %MSIName% %MsiNameWithDate%

2. Advanced Installer [Package Definition] [Builds] [Build Events]
add PostBuild Event
Command = rename_msiname_with_date.bat
Arguments =[|ProductVersion]
Catalin
Posts: 6678
Joined: Wed Jun 13, 2018 7:49 am

Re: Date in installer name?

Hello Aaron and welcome to Advanced Installer forums,

Thank you for sharing your solution with us.

I am sure this will be of help for further users facing a similar scenario.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”