Add Currently logged on Username to property?
Hi!
I have this property that i need to set a folder path with the currently logged on user.
Is this possible without VBS?
For example PATH = C:\testfolder\[USERNAME]_folder\Anotherfolder
Thanks in advance!
// Bartoooo
I have this property that i need to set a folder path with the currently logged on user.
Is this possible without VBS?
For example PATH = C:\testfolder\[USERNAME]_folder\Anotherfolder
Thanks in advance!
// Bartoooo
0 Comments
[ + ] Show comments
Answers (5)
Please log in to answer
Posted by:
Spef
12 years ago
Hi Bartoooo (Surprised I didn’t forget a “o†there)
What is the reason that you don’t want to use a vbs? I only ask this because I ran into a very similar problem however the guy training me up advised me heavily against creating the folder through the MSI tables – this is because the application that I had to do it for required one folder per user that logged on. So in that instance a vbs script in combination with a active script was the best option for me.
Sorry that my answer doesn’t really help as much as it could but I will have a play around and see if I can find anything out this afternoon.
Spef
Hopefully some packaging tips coming to www.spefdata.com
What is the reason that you don’t want to use a vbs? I only ask this because I ran into a very similar problem however the guy training me up advised me heavily against creating the folder through the MSI tables – this is because the application that I had to do it for required one folder per user that logged on. So in that instance a vbs script in combination with a active script was the best option for me.
Sorry that my answer doesn’t really help as much as it could but I will have a play around and see if I can find anything out this afternoon.
Spef
Hopefully some packaging tips coming to www.spefdata.com
Comments:
-
You could use a batch file for this, and use the %USERNAME% environment variable when creating the folder. - Coppr 12 years ago
-
Yea - The best way to do it would be imbed a VBScript/Batch into the MSI and/or active setup but he also said that he hoped to do it without VBS - Spef 12 years ago
-
Why i want to do this without VBS is because i thought it was best practice without VBS but if you say its the best way then maybe i can use it anyway.
I always hear from people that package alot that VBS is "noob-style" :) - Bartoooo 12 years ago
-
The only reason you would need a user-level folder added to the PATH environment variable is for an application to be able to find its support files, which begs the question why you have binaries in the user area? - anonymous_9363 12 years ago
-
Its the application that store some configurationfiles there.
First its C:\Users\\config.ini
And second C:\Users\\anotherfile.cps
The Ini file conatains a path for the "Anotherfile.cps" (And other paths aswell) which stores personalized data for the application.
Default is that the application copies the files to userprofile first time you start the application but now i have solved it by copy the .CPS file from installdir and craete the INI file with VBS. I have also added an Repair entry in Active Setup in the registry som this will happen to all users that logs on.
The problem is that because i distribute the program through SCCM then the %userprofile% variable wont be the user that is currently logged on so i need to log off and on for the file to be created and copied :) Not nice, not nice at all! :=)
I could maybe solve it with WMI in the VBscript but it seems so nooby. If i just could set the username with the property then the application will copy the files instead.
// Bartoooo - Bartoooo 12 years ago
Posted by:
Cosmin Pirvu
12 years ago
Yes, it's possible by using LogonUser predefined property: http://msdn.microsoft.com/en-us/library/windows/desktop/aa369780(v=vs.85).aspx
and a type 51 custom action:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa368237(v=vs.85).aspx
Basically, a custom action can set the folder property to something like:
C:\testfolder\[LogonUser]_folder\Anotherfolder
and a type 51 custom action:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa368237(v=vs.85).aspx
Basically, a custom action can set the folder property to something like:
C:\testfolder\[LogonUser]_folder\Anotherfolder
Comments:
-
Thanks, but i will go with the VBS anyway.
I am going to document this for the future :) - Bartoooo 12 years ago -
Okey turns out that the VBscript is creating some problems and i have tried your way without sucess.
Could you please explain a little bit more in details on how to accomplish this?
// Bartoooo - Bartoooo 12 years ago -
Which setup tool are you using? Also, what went wrong with the approach I suggested? - Cosmin Pirvu 12 years ago
Posted by:
Arminius
12 years ago
It's possible, but I'm concerned about doing that. If there are any features/components in an inconsistently named directory, repairs can get... interesting. Rather than doing that, why not store data in the profile of the logged in user? At least then you'd have a more consistent way of naming and accessing the information in those folders, and repairs/advertised shortcuts/activesetup would be a lot easier.
My $0.02
My $0.02
Comments:
-
The files is actually stored in the userprofile but there is a property containing the Path for that file.
Example:
C:\users\%USER%\config.ini <-- This file contains a Path for the folowing file:
C:\Users\%User%\file.cps.
And this Path is set by a Property!
Its a weird application, i know, but i didnt made it :) - Bartoooo 12 years ago
Posted by:
jmcfadyen
12 years ago
Posted by:
jmcfadyen
12 years ago