Seite 1 von 1

%Username% is always System!

Verfasst: 05 Sep 2014, 14:37
von ebarriosjr
Hello,

i have a littel problem, i am trying to intall a software in the %AppdataDir% of a couple of user but the route is always wrong. When i display the %Username% it says it is always System. What can i do to get the name of the logged user?

Thanks

P.D: The %AppData% is always: C:\Windows\system32\config\systemprofile\AppData\Roaming and i want it to be C:\Users\<username>\AppData\Roaming

Re: %Username% is always System!

Verfasst: 08 Sep 2014, 08:50
von n.wenselowski
Hello,

the username System is correct because the opsi-winst runs in the System-context.

There are some switches to winst sections that begin with /AllNTUser. You should have a look at them in the winst manual.

Otherwise we would need some more information on how the section looks and how it is called.


With kind regards

Niko

Re: %Username% is always System!

Verfasst: 08 Sep 2014, 14:08
von ebarriosjr
Hello again,

i need to get the name of user that is logged or the last logged user will work to. I trie to copy this data from the registry with:

Code: Alles auswählen

Set $local_user$ = GetRegistryStringValue("[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders] AppData")
and with

Code: Alles auswählen

Set $local_user$ = GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI] LastLoggedOnSAMUser")
and with

Code: Alles auswählen

Set $local_user$ = GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI] LastLoggedOnUser")
But it comes always empty....

The programm that i am triying to in stall needs to go in the C:\Users\<username>\AppData\Roaming. How can i know the name of the logged user? I cant install it for all users.....

Please help me...

Best regards

Re: %Username% is always System!

Verfasst: 08 Sep 2014, 16:22
von n.wenselowski
Hello,

the easiest way is probably to do this with the User Profile Management extension because then you can use i.e. GetLoggedInUser.
Also what I am thinking of is to use an opsi service call like hostControlSafe_getActiveSessions to see who is logged on.
But I am not specialist for opsiscript so there may be an easier way to do this.

Also I recommend a support contract.


With kind regards

Niko

Re: %Username% is always System!

Verfasst: 16 Sep 2014, 14:13
von ebarriosjr
Hi again,

i am using the evaluation of the User Profile Management extension. And if i set $User$ = GetLoggedInUser i get the right user. But all the varibles %AppDataDir%, etc etc are not set correctly. The installer that i am using generates a token based on this variables.

Is there any command to run the installer as the loggedinUser with admin rights?

Maybe winbatch /RunAsLoggedInUser or something like that?

Best regards

Re: %Username% is always System!

Verfasst: 18 Sep 2014, 19:46
von d.oertel
Hi,

running with the user-profile-management extension in profile mode %AppdataDir% should be correct for the logged in user.

What did you get ?
Maybe winbatch /RunAsLoggedInUser or something like that?
This will start the process in the context of the logged in user (while in profile mode) .

regards

d.oertel

Re: %Username% is always System!

Verfasst: 23 Sep 2014, 11:12
von ritsovih
just a fyi, since d.oertel's suggestion (user-profile-management) is probably better, but it is possible to run programs as the logged on user, even if you start the original process as SYSTEM

https://www-304.ibm.com/support/docview ... wg21506033

https://github.com/MicksMix/RunAsLou/bl ... nAsLOU.exe (didn't test this one myself)

both allow you to run programs/scripts as the logged on user, provided the original process starts as SYSTEM

for instance if the logged on user is JoeSchmoe : running RunAsCurrentUser-2.0.3.1.exe notepad as SYSTEM will start notepad.exe as JoeShmoe

this isn't much use for normal opsi operation, since most opsi actions run at system boot, before any user (except SYSTEM) is logged on.