Inno Setup - {drive:src} is not returning mapped drive letter in Win7 and Win8

1.1k views Asked by At

During Installation I am writing drive letter ({drive:src}) of source into {app}/userinfo.ini and {localappdata}/userinfo.ini files, which is working fine in WinXP and Vista but not in Win7 and Win8. In {app}/userinfo.ini it is always writing "C:" if the source is a mapped drive and in {localappdata}/UserInfo.ini it is writing full network path of the source. I read that the privileges are different for Win7 and Win8 users. Then how to get the mapped drive letter in this case.

1

There are 1 answers

0
Miral On

You cannot get the mapped drive letter, as the installer runs as an administrator and the drive mappings are different between admin and non-admin levels (even if you think it's the same user -- and it isn't always).

When elevating from regular to admin, Inno automatically translates mapped drive letters to the "real" UNC path, as it would not be able to run at all if it tried to use the letter. Thus {src} will always be a UNC path, and {drive:src} will be the root share name.

You shouldn't be trying to save this information in an admin installation anyway, as different users may have different mappings. You will either need to make your application figure this out itself (and save it in the per-user settings) or you will need to make a per-user installation instead.