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!

cadull
Posts: 12
Joined: Thu Feb 27, 2020 11:09 pm

Spaces and trailing backslash issue when passed to custom action

Attached sample project creates 4 properties. Only the last one contains a space and has a trailing backslash.

Code: Select all

TEST1 = "C:\ProgramData"
TEST2 = "C:\ProgramData\"
TEST3 = "C:\Program Files"
TEST4 = "C:\Program Files\"
When passed to a PowerShell custom action, in property TEST4 the trailing backslash is used to escape the quote character which is introduced into the variable $test4.

Code: Select all

-test1 "[TEST1]" -test2 "[TEST2]" -test3 "[TEST3]" -test4 "[TEST4]"

Param($test1, $test2, $test3, $test4)

icacls $test1
icacls $test2
icacls $test3
icacls $test4
This causes an error running the command icacls for $test4.
Attachments
Sample.aip
(14.22 KiB) Downloaded 287 times
cadull
Posts: 12
Joined: Thu Feb 27, 2020 11:09 pm

Re: Spaces and trailing backslash issue when passed to custom action

Found that this is just the way command line arguments are processed (i.e. as passed to icacls).

There is a FAQ for removing the trailing backslash with VBScript.

In PowerShell, I've used:

Code: Select all

$test4.TrimEnd('\')
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Spaces and trailing backslash issue when passed to custom action

Hello,

Thank you for your followup on this and for sharing your solution with us.

I am sure this might come in handy for further users facing a similar scenario.

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

Return to “Common Problems”