We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

kid1519
Posts: 10
Joined: Tue Feb 11, 2014 7:18 am

HELP

HELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELPHELP
Last edited by kid1519 on Tue May 16, 2017 11:41 am, edited 1 time in total.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: [VBS]: Get Bios Serial Number then write to registry

Hello,

In order to retrieve the BIOS Information you can create your own custom action. If you want to use the VBS approach, you can take a look on the Retreving BIOS Information article which may be useful to you.
Please note that you can create your custom action as a custom action written in C# or a custom action written in C++, instead of VBScript and you can see some reasons why not to use VBScript.

Within this custom action, you can also set properties with the related values which you want to write in the registry. Since you are using the VBScipt approach, in order to set a property with a value, you can use the the following statement:

Code: Select all

Session.Property("MY_PROP") = value
In order to launch your custom action, you can go in the “Custom Actions” page and add a predefined Launch attached file custom action with sequence. This type of custom action can execute an application (EXE or DLL) or run a script (VBScript or Java script). Also, the source file will be embedded in the MSI file but will not be deployed at install time with the other application files.

Please note that you don't have to write these values into registry within your custom action, as you can use our support for Add registry keys and values to your package. If you need to write the related registry values within your custom action, please take a look on the Creating a Registry Key article which may be useful to you.

If you have other questions, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kid1519
Posts: 10
Joined: Tue Feb 11, 2014 7:18 am

Re: [VBS]: Get Bios Serial Number then write to registry

Dan wrote:Hello,

In order to retrieve the BIOS Information you can create your own custom action. If you want to use the VBS approach, you can take a look on the Retreving BIOS Information article which may be useful to you.
Please note that you can create your custom action as a custom action written in C# or a custom action written in C++, instead of VBScript and you can see some reasons why not to use VBScript.

Within this custom action, you can also set properties with the related values which you want to write in the registry. Since you are using the VBScipt approach, in order to set a property with a value, you can use the the following statement:

Code: Select all

Session.Property("MY_PROP") = value
In order to launch your custom action, you can go in the “Custom Actions” page and add a predefined Launch attached file custom action with sequence. This type of custom action can execute an application (EXE or DLL) or run a script (VBScript or Java script). Also, the source file will be embedded in the MSI file but will not be deployed at install time with the other application files.

Please note that you don't have to write these values into registry within your custom action, as you can use our support for Add registry keys and values to your package. If you need to write the related registry values within your custom action, please take a look on the Creating a Registry Key article which may be useful to you.

If you have other questions, please let us know.

Best regards,
Dan
Dear Dan,
First, Thank you so much. This is the longest and best guide i've ever read.
With my vbscript: I finished 95% but i don't know use:
strValue = ???
i try:
strValue = ("Serial Number: " & objBIOS.SerialNumber)
but it isn't working.
I also don't know use a custom action written in C# or a custom action written in C++ (i am reading them from your guide)
Why do i have this topic?
->>> Because i wrote a simple software: only a .exe file.
Althought, it is a simple software, but i want use Advanced Installer for setup wizard because i like Advanced Installer very much. But everyone can copy it after setup complete at: [ProgramFilesFolder][Manufacturer]\[ProductName] and copy and share...blah blah...
I want everyone must use setup wizard: How to create?
- Advanced Installer: a custom action written in vbscript: check Bios Serial Number then write to registry.
- my simple software: It check Bios Serial Number and check registry. If value's Bios Serial Number = vavlue's registry. Ok
If value is different then exit software.
Of course, i know use a custom action exe but i don't like. i need use script.
Can you help me more?
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: [VBS]: Get Bios Serial Number then write to registry

Hello,
With my vbscript: I finished 95% but i don't know use:
strValue = ???
i try:
strValue = ("Serial Number: " & objBIOS.SerialNumber)
but it isn't working.
First of all, you should define a public property in the Install Parameters page. (in my example is MY_REG_PROP). In order to set the MY_REG_PROP public property, you should use something like that:

Code: Select all

Session.Property("MY_REG_PROP")=objBIOS.SerialNumber
So, your custom action code can look something like that:

Code: Select all

Function LaunchVBS_Sample( )

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")
For each objBIOS in colBIOS
    x=msgbox("Serial Number: " & objBIOS.SerialNumber)
    Session.Property("MY_REG_PROP")=objBIOS.SerialNumber	
Next

End Function
In order to launch your custom action, you can go in the “Custom Actions” page and add a predefined Launch attached file custom action with sequence after the Searches stage from the Install Execution Stage.

So, the MY_REG_PROP property contains the Bios Serial Number. In order to write this value into the registry, you can take a look on the Add registry keys and values to your package article with related information for hints and guidance.

I've attached an .AIP(advanced installer project) which implements this scenario.

Observation !
During my tests, I've noticed that the VBS custom action cannot retrieve the Bios Serial Number all time. Not sure why. That's why I've attached the following custom actions:
  • CA.vbs - if the message box does not contains your bios serial number then you can be sure that it will not work either in the installer; ( you can run this custom action as a test)
  • CA_AI.vbs - this custom action is used in the .AIP
Althought, it is a simple software, but i want use Advanced Installer for setup wizard because i like Advanced Installer very much. But everyone can copy it after setup complete at: [ProgramFilesFolder][Manufacturer]\[ProductName] and copy and share...blah blah...
I want everyone must use setup wizard: How to create?
Since the bios serial number cannot be retrieved using the above custom action, you can search in your .EXE if a specific registry entry can be found on the target machine. This registry entry can be made using our Add registry keys and values to your package support.

Since the related registry entry is made by the installation package, if the specific registry entry cannot be found on the target machine, then you can exit your application. Basically you can search in the registry, every time your run your application and see if that registry entry exist.

Please note that there is a better way to protect your application and this can be done using our Licensing support. Please take a look on the Advanced Installer - Licensing How To's in order to see how this feature can be used.

If you have other questions, please let us know.

Best regards,
Dan
Attachments
GetBios Serial Number then write to registry.zip
(3.23 KiB) Downloaded 449 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kid1519
Posts: 10
Joined: Tue Feb 11, 2014 7:18 am

Re: [VBS]: Get Bios Serial Number then write to registry

Dan wrote:Hello,
With my vbscript: I finished 95% but i don't know use:
strValue = ???
i try:
strValue = ("Serial Number: " & objBIOS.SerialNumber)
but it isn't working.
First of all, you should define a public property in the Install Parameters page. (in my example is MY_REG_PROP). In order to set the MY_REG_PROP public property, you should use something like that:

Code: Select all

Session.Property("MY_REG_PROP")=objBIOS.SerialNumber
So, your custom action code can look something like that:

Code: Select all

Function LaunchVBS_Sample( )

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")
For each objBIOS in colBIOS
    x=msgbox("Serial Number: " & objBIOS.SerialNumber)
    Session.Property("MY_REG_PROP")=objBIOS.SerialNumber	
Next

End Function
In order to launch your custom action, you can go in the “Custom Actions” page and add a predefined Launch attached file custom action with sequence after the Searches stage from the Install Execution Stage.

So, the MY_REG_PROP property contains the Bios Serial Number. In order to write this value into the registry, you can take a look on the Add registry keys and values to your package article with related information for hints and guidance.

I've attached an .AIP(advanced installer project) which implements this scenario.

Observation !
During my tests, I've noticed that the VBS custom action cannot retrieve the Bios Serial Number all time. Not sure why. That's why I've attached the following custom actions:
  • CA.vbs - if the message box does not contains your bios serial number then you can be sure that it will not work either in the installer; ( you can run this custom action as a test)
  • CA_AI.vbs - this custom action is used in the .AIP
Althought, it is a simple software, but i want use Advanced Installer for setup wizard because i like Advanced Installer very much. But everyone can copy it after setup complete at: [ProgramFilesFolder][Manufacturer]\[ProductName] and copy and share...blah blah...
I want everyone must use setup wizard: How to create?
Since the bios serial number cannot be retrieved using the above custom action, you can search in your .EXE if a specific registry entry can be found on the target machine. This registry entry can be made using our Add registry keys and values to your package support.

Since the related registry entry is made by the installation package, if the specific registry entry cannot be found on the target machine, then you can exit your application. Basically you can search in the registry, every time your run your application and see if that registry entry exist.

Please note that there is a better way to protect your application and this can be done using our Licensing support. Please take a look on the Advanced Installer - Licensing How To's in order to see how this feature can be used.

If you have other questions, please let us know.

Best regards,
Dan
Dear Dan,
Thank you so much
This is everything i need.
I am going to read and learn from your guide.
Althought, This guide is long but it is very perfect for me. I know more knowledge from this guide. I will learn it step by step.
thank you for your enthusiasm.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: [VBS]: Get Bios Serial Number then write to registry

You're welcome,

Take your time, the learning curve is steep at first but once you get the hang of Advanced Installer you'll be set authoring packages with any requirements.

Our user guide has the exact steps but if you encounter any specific blockers, we're here to help.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kid1519
Posts: 10
Joined: Tue Feb 11, 2014 7:18 am

Re: [VBS]: Get Bios Serial Number then write to registry

Dan wrote:You're welcome,

Take your time, the learning curve is steep at first but once you get the hang of Advanced Installer you'll be set authoring packages with any requirements.

Our user guide has the exact steps but if you encounter any specific blockers, we're here to help.

Best regards,
Dan
Thank you so much to Dan,
Can you tell me more about: "Temp" while I use "Launch attached file custom action": .exe, .msi, . vbs, ....ect...
If I use "Launch attached file custom action" -> Maybe at: "[AppDataFolder][|Manufacturer]\[|ProductName] [|ProductVersion]\install". This folder contains all files. But I don't like everyone know file which "Launch attached file custom action".
How to do???
thank for reply
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: [VBS]: Get Bios Serial Number then write to registry

Hello,

Please note that using the Launch attached file custom action you can execute an application (EXE or DLL) or run a script (VB or Java script) which is not among your project files. This source file will be embedded in the MSI file but will not be deployed at install time with the other application files and also it will not be deployed to the AppDataFolder.

Did you encountered another behavior?

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”