%Username% is always System!
- ebarriosjr
- Beiträge: 26
- Registriert: 24 Jun 2014, 11:03
%Username% is always System!
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
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
- n.wenselowski
- Ex-uib-Team
- Beiträge: 3194
- Registriert: 04 Apr 2013, 12:15
Re: %Username% is always System!
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
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
Code: Alles auswählen
import OPSI
- ebarriosjr
- Beiträge: 26
- Registriert: 24 Jun 2014, 11:03
Re: %Username% is always System!
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:
and with
and with
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
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")
Code: Alles auswählen
Set $local_user$ = GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI] LastLoggedOnSAMUser")
Code: Alles auswählen
Set $local_user$ = GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI] LastLoggedOnUser")
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
- n.wenselowski
- Ex-uib-Team
- Beiträge: 3194
- Registriert: 04 Apr 2013, 12:15
Re: %Username% is always System!
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
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
Code: Alles auswählen
import OPSI
- ebarriosjr
- Beiträge: 26
- Registriert: 24 Jun 2014, 11:03
Re: %Username% is always System!
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
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!
Hi,
running with the user-profile-management extension in profile mode %AppdataDir% should be correct for the logged in user.
What did you get ?
regards
d.oertel
running with the user-profile-management extension in profile mode %AppdataDir% should be correct for the logged in user.
What did you get ?
This will start the process in the context of the logged in user (while in profile mode) .Maybe winbatch /RunAsLoggedInUser or something like that?
regards
d.oertel
Vielen Dank für die Nutzung von opsi. Im Forum ist unser Support begrenzt.
Für den professionellen Einsatz und individuelle Beratung empfehlen wir einen Support-Vertrag und eine Schulung.
Gerne informieren wir Sie zu unserem Angebot.
uib GmbH
Telefon: +49 6131 27561 0
E-Mail: sales@uib.de
Re: %Username% is always System!
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.
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.