MSI: Create or rename a folder to the logged on user's userID
Ok, this is a weird one. I've been given an application to package into an MSI, the developers want the MSI to be able to create a folder with the logged on user's userID (C:\Program Files\MyApp\<UserID>\). We deploy applications to machines and any user specific stuff (user profile, HKCU, etc) is usually handled with Active Setup. Can this be achieved using Active Setup?
... and No, I don't know why they couldn't have developed their application to use AppData!!
Answers (4)
The username variable could be used with Custom Action "Set Directory" Custom Action Type 35. First create a directory "userIDFolder". Then create a custom action in execute sequence that changes the path of this directory to C:\Program Files\MyApp\%username%, with the help of Custom Action Type 35
This can be achieved using ActiveSetup or DuplicateFile table... In both cases, you have to give "Write Permission" to the "C:\Program Files\MyApp" folder.
Comments:
-
How would that automatically create or rename a folder to the logged on user's userID? - jlai 12 years ago
-
Yes.. As Visalakshi said, Create a VBScript which will create a folder with the currently logged in USERNAME in C:\Program Files\Myapp folder, keep this VBScript in C:\Program Files\MyApp folder . Call this vbscript in Active setup... - jagadeish 12 years ago
-
Thanks. - jlai 12 years ago
Give permisions to C:\Program Files\Myapp. Create a VB script which will create a folder in C:\Program Files\Myapp. Call this vbscript in Active setup.
Comments:
-
Thanks, I didn't realise you could have more than one Active Setup per MSI. I'll have a look at this too. So the stub Path would be: wscript.exe myscript.vbs - jlai 12 years ago
The username variable could be used with Custom Action "Set Directory" Custom Action Type 35.
First create a directory "userIDFolder".
Then create a custom action in execute sequence that changes the path of this directory to C:\Program Files\MyApp\%username%, with the help of Custom Action Type 35.