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!

philb1208
Posts: 44
Joined: Thu Jul 04, 2019 3:24 pm

Drive Selection

Hi,

When i run the installer to install my windows service, i need to show a list of all available drive instances on a local machine. From there i want to be able to select the drive instances i want. When the installer completes a config file is output with these drives instances included. Then my service only watches these instances.

How can we do this with the Advanced Installer? I know how to append the information to a file during installation, just struggling to work out how to present the available drives with tick boxes in the GUI.

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

Re: Drive Selection

Hello Phill,

Since I've spent quite some time developing this, I have created a little How-To (in hope that other users may find it useful as well) for this. Please find it here:

viewtopic.php?f=7&t=44919

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
philb1208
Posts: 44
Joined: Thu Jul 04, 2019 3:24 pm

Re: Drive Selection

Thanks Catalin! Looks quite detailed I'll have a look this afternoon:)

thank you
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Drive Selection

You are always welcome, Phill!

Hope that will be of help for you.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
philb1208
Posts: 44
Joined: Thu Jul 04, 2019 3:24 pm

Re: Drive Selection

Hi,

i'm only just getting chance to work on this, I've got the drive selection part working based on the guide you provided. I've changed the replace part slightly to drop the \ from the drive name as i need to pass it to a configuration file and the \ part would break it. At the moment I'm getting this output

A:,C:,D:

How can i modify the powershell script in your guide to wrap each drive letter select in double quotes, like so

"A:","C:","D:"

I've had an attempt at this, but i get mixed results, either the double quotes are before the drive letter or the entire string is wrapped in double quotes. Little bit confused.
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Drive Selection

Hello Phil,
I've had an attempt at this, but i get mixed results, either the double quotes are before the drive letter or the entire string is wrapped in double quotes. Little bit confused.
That's ok, we got this.

In PowerShell, the double quotes character (") has a special meaning (also the single quote). Let's have a look on the following example:

We have a variable to which we assign a value, i.e.:

Code: Select all

$var = "string"
If we encapsule our variable between single quotes:

Code: Select all

'$var'
the shell will return the following:

Code: Select all

$var
As it can be seen, the shell will return the name of the variable.

When encapsuled between double quotes:

Code: Select all

"$var"
the shell will return:

Code: Select all

string
As it can be seen, the shell will now return the value of the variable.

Normally, when you want to use a single/double quote inside another double quote, the characters must be escaped. The escape character (`) will tell the shell that it needs to take the literal value. For example, if we want to print in the shell the following string:
The value of $var is string
we will use something similar to this:

Code: Select all

"The value of `$var is $var"
PS.png
PS.png (65.32 KiB) Viewed 4887 times

Now, coming back to the main problem. If you want to encapsule between double quotes each element of the array, you can proceed as it follows:

Code: Select all

$drives = Get-PsDrive -PSProvider FileSystem | Select Root
for($i = 0; $i -lt $drives.Count; $i++){

$temp = -join ($drives[$i].Root,'|')

$new += "`"$temp`""

}

Notice that when we create the $new variable, we have escaped the double quote character. The two furthermost (first and last) quotes have the job to expand the value of the $temp variable while the escaped quotes have the job encapsule them between quotes.

Hope this helps and I hope you don't mind the little explanation.

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

Return to “Building Installers”