Old 30th January 2014, 21:11   #1
Junior Member
Bansaw's Avatar
Join Date: Jul 2010
Posts: 32
How do I get the name of the current logged in user ?

I am running my installer with "admin" privileges and not "highest".
This means that some people in the office require an admin person to come along and log so the installer can start.

However, my installer needs to find out the username of the person who launched the installer.
I tried this: ReadRegStr $0 HKCU "Volatile Environment" "USERNAME"

This worked on my machine and other machines I was logged into, but it didn't work on peoples machines who were not admins or had any kind of elevated privileges.

I also looked at:
System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"

But this simply returns the name of the admin who has come along and logged in, and not the user who originally launched it.

How do I get the name of the person who originally launched my installer?
Bansaw is offline   Reply With Quote
Old 30th January 2014, 21:36   #2
Major Dude
Join Date: Feb 2007
Posts: 672
jpderuiter is offline   Reply With Quote
Old 30th January 2014, 22:05   #3
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,418
When you are asking for this type of information you are probably doing something wrong.

When you set RequestExecutionLevel admin you are doing a machine/all users install and you should put your stuff under $ProgramFiles and HKLM.

If you need to do some per-user stuff then this should really happen the first time your application runs as that user (Copy template data from the install directory to $appdata etc) The "Active Setup" registry key can also be helpful...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump