Solved: AllUserProfile in Files Sektion funktioniert nicht

Antworten
toddi
Beiträge: 12
Registriert: 17 Mai 2018, 07:24

Solved: AllUserProfile in Files Sektion funktioniert nicht

Beitrag von toddi »

Moin zusammen,

ich versuche in der Files Sektion mit dem /AllUsersProfile Parameter Dateien zu kopieren. Allerdings scheint opsi %UserProfileDir% nicht korrekt aufzulösen. In der Patch Sektion funktioniert es.

Hier der Code:

Code: Alles auswählen

Set $UserPath$ = "%UserProfileDir%\AppData\local\TestScript\"
Files_CreateUserFiles /AllUserProfile

[Files_CreateUserFiles]
copy "%ScriptPath%\test.txt" "$UserPath$"
Das passiert dann:

Code: Alles auswählen

(375)     [5] [2024-11-26 14:13:54.171] [wh-test] Execution of: Files_CreateUserFiles /AllUserProfile
(381)     [7] [2024-11-26 14:13:54.171] [wh-test] copy "s:\wh-test\test.txt" "%UserProfileDir%\AppData\local\TestScript\"
(382)     [7] [2024-11-26 14:13:54.171] [wh-test] copy
(384)     [6] [2024-11-26 14:13:54.173] [wh-test] path C:\Windows\system32\%UserProfileDir%\AppData\local\TestScript\ created
(387)     [6] [2024-11-26 14:13:54.329] [wh-test] Copying  s:\wh-test\test.txt -----> C:\Windows\system32\%UserProfileDir%\AppData\local\TestScript\
(388)     [6] [2024-11-26 14:13:54.329] [wh-test] 1 File(s) found
(391)     [7] [2024-11-26 14:13:54.338] [wh-test] Source s:\wh-test\test.txt
(393)     [6] [2024-11-26 14:13:54.394] [wh-test] copy: s:\wh-test\test.txt copied to C:\Windows\system32\%UserProfileDir%\AppData\local\TestScript\
(394)     [6] [2024-11-26 14:13:54.399] [wh-test] 1 File(s) treated
Ändere ich den Code so:

Code: Alles auswählen

Set $UserPath$ = "\AppData\local\TestScript\"
Files_CreateUserFiles /AllUserProfile

[Files_CreateUserFiles]
copy "%ScriptPath%\test.txt" "%UserProfileDir%$UserPath$"
Passiert das:

Code: Alles auswählen

(375)     [5] [2024-11-26 14:07:32.538] [wh-test] Execution of: Files_CreateUserFiles /AllUserProfile
(381)     [7] [2024-11-26 14:07:32.538] [wh-test] copy "s:\wh-test\test.txt" "\AppData\local\TestScript\"
(382)     [7] [2024-11-26 14:07:32.538] [wh-test] copy
(384)     [6] [2024-11-26 14:07:32.541] [wh-test] path C:\AppData\local\TestScript\ created
(387)     [6] [2024-11-26 14:07:32.633] [wh-test] Copying  s:\wh-test\test.txt -----> C:\AppData\local\TestScript\
(388)     [6] [2024-11-26 14:07:32.633] [wh-test] 1 File(s) found
(391)     [7] [2024-11-26 14:07:32.638] [wh-test] Source s:\wh-test\test.txt
(393)     [6] [2024-11-26 14:07:32.673] [wh-test] copy: s:\wh-test\test.txt copied to C:\AppData\local\TestScript\
(394)     [6] [2024-11-26 14:07:32.674] [wh-test] 1 File(s) treated
Verwendet wird winst Version: 4.12.16.1

Für mich sieht es so aus, als würde winst die Variable %UserProfileDir% nicht auflösen. Sofern ich nicht einen Fehler gemacht habe.

Grüße, Torsten
Zuletzt geändert von toddi am 11 Dez 2024, 10:32, insgesamt 1-mal geändert.
Benutzeravatar
n.doerrer
uib-Team
Beiträge: 408
Registriert: 23 Okt 2020, 16:11

Re: AllUserProfile in Files Sektion funktioniert nicht

Beitrag von n.doerrer »

Moin,

das sollte vermutlich "AllUserProfiles" sein.
https://docs.opsi.org/opsi-docs-de/4.3/ ... -allntuser

Funktioniert es damit?


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


toddi
Beiträge: 12
Registriert: 17 Mai 2018, 07:24

Re: AllUserProfile in Files Sektion funktioniert nicht

Beitrag von toddi »

Up, das war ein Fehler, aber nicht die Lösung des Problems.

Nach dem korrigieren kommt zumindest wieder die Enumeration der User, aber leider bleibt das Problem mit der Variable bestehen.
Hier die Logausgabe:

Code: Alles auswählen

(889)     [5] [2024-12-09 12:43:32.916] [wh-test] Execution of: Files_CreateUserFiles /AllUserProfiles
(891)     [7] [2024-12-09 12:43:32.916] [wh-test] Registry started without redirection (64 Bit)
(892)     [7] [2024-12-09 12:43:32.916] [wh-test] Registry started readonly
(893)     [7] [2024-12-09 12:43:32.916] [wh-test] Registry started without redirection (64 Bit)
(894)     [6] [2024-12-09 12:43:32.916] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-18] opened
(895)     [6] [2024-12-09 12:43:32.917] [wh-test] Key closed
(896)     [7] [2024-12-09 12:43:32.917] [wh-test] Registry started readonly
(897)     [7] [2024-12-09 12:43:32.917] [wh-test] Registry started without redirection (64 Bit)
(898)     [6] [2024-12-09 12:43:32.917] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-19] opened
(899)     [6] [2024-12-09 12:43:32.917] [wh-test] Key closed
(900)     [7] [2024-12-09 12:43:32.917] [wh-test] Registry started readonly
(901)     [7] [2024-12-09 12:43:32.917] [wh-test] Registry started without redirection (64 Bit)
(902)     [6] [2024-12-09 12:43:32.917] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20] opened
(903)     [6] [2024-12-09 12:43:32.917] [wh-test] Key closed
(904)     [7] [2024-12-09 12:43:32.917] [wh-test] Registry started readonly
(905)     [7] [2024-12-09 12:43:32.917] [wh-test] Registry started without redirection (64 Bit)
(906)     [6] [2024-12-09 12:43:32.917] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-...] opened
(907)     [6] [2024-12-09 12:43:32.917] [wh-test] Key closed
(908)     [7] [2024-12-09 12:43:32.917] [wh-test] Registry started readonly
(909)     [7] [2024-12-09 12:43:32.917] [wh-test] Registry started without redirection (64 Bit)
(910)     [6] [2024-12-09 12:43:32.917] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-...] opened
(911)     [6] [2024-12-09 12:43:32.917] [wh-test] Key closed
(912)     [6] [2024-12-09 12:43:32.917] [wh-test]  Make it for user directory: C:\Users\AAAAAAAAA\
(917)     [7] [2024-12-09 12:43:32.918] [wh-test] copy "s:\wh-test\test.txt" "%UserProfileDir%\AppData\local\TestScript\"
(918)     [7] [2024-12-09 12:43:32.918] [wh-test] copy
(920)     [3] [2024-12-09 12:43:32.919] [wh-test] Error:  Directory C:\Users\AAAAAAAAA "%UserProfileDir%\AppData\local\TestScript\" does not exist and cannot be created
(921)     [6] [2024-12-09 12:43:32.919] [wh-test]  Make it for user directory: C:\Users\BBBBBBB\
(926)     [7] [2024-12-09 12:43:32.919] [wh-test] copy "s:\wh-test\test.txt" "%UserProfileDir%\AppData\local\TestScript\"
(927)     [7] [2024-12-09 12:43:32.919] [wh-test] copy
(929)     [3] [2024-12-09 12:43:32.921] [wh-test] Error:  Directory C:\Users\BBBBBBB "%UserProfileDir%\AppData\local\TestScript\" does not exist and cannot be created
(930)     [6] [2024-12-09 12:43:32.921] [wh-test]  Make it for user directory: C:\Users\Default\
(935)     [7] [2024-12-09 12:43:32.921] [wh-test] copy "s:\wh-test\test.txt" "%UserProfileDir%\AppData\local\TestScript\"
(936)     [7] [2024-12-09 12:43:32.921] [wh-test] copy
(938)     [3] [2024-12-09 12:43:32.921] [wh-test] Error:  Directory C:\Users\Default "%UserProfileDir%\AppData\local\TestScript\" does not exist and cannot be created
(939)     [5] [2024-12-09 12:43:32.921] [wh-test] Finished section: Files_CreateUserFiles /AllUserProfiles
Grüße, Torsten
Benutzeravatar
j.werner
uib-Team
Beiträge: 86
Registriert: 08 Okt 2019, 13:32

Re: AllUserProfile in Files Sektion funktioniert nicht

Beitrag von j.werner »

Hallo,
bitte %CurrentProfileDir% verwenden, damit sollte es wie gewünscht funktionieren.

Viele Grüße
Jan


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


toddi
Beiträge: 12
Registriert: 17 Mai 2018, 07:24

Re: AllUserProfile in Files Sektion funktioniert nicht

Beitrag von toddi »

Hallo Jan,

das habe ich gemacht, hat aber leider auch nicht funktioniert. Jetzt passiert das folgende:

Code: Alles auswählen

(1394)    [5] [2024-12-11 10:17:13.661] [wh-test] Execution of: Files_CreateUserFiles /AllUserProfiles
(1396)    [7] [2024-12-11 10:17:13.668] [wh-test] Registry started without redirection (64 Bit)
(1397)    [7] [2024-12-11 10:17:13.669] [wh-test] Registry started readonly
(1398)    [7] [2024-12-11 10:17:13.669] [wh-test] Registry started without redirection (64 Bit)
(1399)    [6] [2024-12-11 10:17:13.669] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-18] opened
(1400)    [6] [2024-12-11 10:17:13.669] [wh-test] Key closed
(1401)    [7] [2024-12-11 10:17:13.669] [wh-test] Registry started readonly
(1402)    [7] [2024-12-11 10:17:13.669] [wh-test] Registry started without redirection (64 Bit)
(1403)    [6] [2024-12-11 10:17:13.669] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-19] opened
(1404)    [6] [2024-12-11 10:17:13.670] [wh-test] Key closed
(1405)    [7] [2024-12-11 10:17:13.670] [wh-test] Registry started readonly
(1406)    [7] [2024-12-11 10:17:13.670] [wh-test] Registry started without redirection (64 Bit)
(1407)    [6] [2024-12-11 10:17:13.670] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20] opened
(1408)    [6] [2024-12-11 10:17:13.671] [wh-test] Key closed
(1409)    [7] [2024-12-11 10:17:13.671] [wh-test] Registry started readonly
(1410)    [7] [2024-12-11 10:17:13.671] [wh-test] Registry started without redirection (64 Bit)
(1411)    [6] [2024-12-11 10:17:13.671] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-...] opened
(1412)    [6] [2024-12-11 10:17:13.671] [wh-test] Key closed
(1413)    [7] [2024-12-11 10:17:13.671] [wh-test] Registry started readonly
(1414)    [7] [2024-12-11 10:17:13.671] [wh-test] Registry started without redirection (64 Bit)
(1415)    [6] [2024-12-11 10:17:13.671] [wh-test] Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-...] opened
(1416)    [6] [2024-12-11 10:17:13.671] [wh-test] Key closed
(1417)    [6] [2024-12-11 10:17:13.671] [wh-test]  Make it for user directory: C:\Users\AAAAAAAAA\
(1422)    [7] [2024-12-11 10:17:13.671] [wh-test] copy "s:\wh-test\test.txt" "C:\Windows\System32\config\systemprofile\AppData\local\TestScript\"
(1423)    [7] [2024-12-11 10:17:13.671] [wh-test] copy
(1425)    [6] [2024-12-11 10:17:13.672] [wh-test] path C:\Windows\System32\config\systemprofile\AppData\local\TestScript\ created
(1428)    [6] [2024-12-11 10:17:13.686] [wh-test] Copying  s:\wh-test\test.txt -----> C:\Windows\System32\config\systemprofile\AppData\local\TestScript\
(1429)    [6] [2024-12-11 10:17:13.686] [wh-test] 1 File(s) found
(1432)    [7] [2024-12-11 10:17:13.692] [wh-test] Source s:\wh-test\test.txt
(1434)    [6] [2024-12-11 10:17:13.718] [wh-test] copy: s:\wh-test\test.txt copied to C:\Windows\System32\config\systemprofile\AppData\local\TestScript\
(1435)    [6] [2024-12-11 10:17:13.719] [wh-test] 1 File(s) treated
(1436)    [6] [2024-12-11 10:17:13.728] [wh-test]  Make it for user directory: C:\Users\BBBBBBB\
(1441)    [7] [2024-12-11 10:17:13.728] [wh-test] copy "s:\wh-test\test.txt" "C:\Windows\System32\config\systemprofile\AppData\local\TestScript\"
(1442)    [7] [2024-12-11 10:17:13.728] [wh-test] copy
(1446)    [6] [2024-12-11 10:17:13.729] [wh-test] Copying  s:\wh-test\test.txt -----> C:\Windows\System32\config\systemprofile\AppData\local\TestScript\
(1447)    [6] [2024-12-11 10:17:13.729] [wh-test] 1 File(s) found
(1450)    [7] [2024-12-11 10:17:13.733] [wh-test] Source s:\wh-test\test.txt
(1451)    [7] [2024-12-11 10:17:13.733] [wh-test] Info: Target C:\Windows\System32\config\systemprofile\AppData\local\TestScript\test.txt exists and shall be overwritten
(1453)    [6] [2024-12-11 10:17:13.745] [wh-test] copy: s:\wh-test\test.txt copied to C:\Windows\System32\config\systemprofile\AppData\local\TestScript\
(1454)    [6] [2024-12-11 10:17:13.746] [wh-test] 1 File(s) treated
(1455)    [6] [2024-12-11 10:17:13.755] [wh-test]  Make it for user directory: C:\Users\Default\
(1460)    [7] [2024-12-11 10:17:13.755] [wh-test] copy "s:\wh-test\test.txt" "C:\Windows\System32\config\systemprofile\AppData\local\TestScript\"
(1461)    [7] [2024-12-11 10:17:13.755] [wh-test] copy
(1465)    [6] [2024-12-11 10:17:13.756] [wh-test] Copying  s:\wh-test\test.txt -----> C:\Windows\System32\config\systemprofile\AppData\local\TestScript\
(1466)    [6] [2024-12-11 10:17:13.756] [wh-test] 1 File(s) found
(1469)    [7] [2024-12-11 10:17:13.758] [wh-test] Source s:\wh-test\test.txt
(1470)    [7] [2024-12-11 10:17:13.758] [wh-test] Info: Target C:\Windows\System32\config\systemprofile\AppData\local\TestScript\test.txt exists and shall be overwritten
(1472)    [6] [2024-12-11 10:17:13.770] [wh-test] copy: s:\wh-test\test.txt copied to C:\Windows\System32\config\systemprofile\AppData\local\TestScript\
(1473)    [6] [2024-12-11 10:17:13.772] [wh-test] 1 File(s) treated
(1474)    [5] [2024-12-11 10:17:13.777] [wh-test] Finished section: Files_CreateUserFiles /AllUserProfiles
Ergibt für mich auch in sofern Sinn, da opsi mit dem Benutzer System läuft.

Allerdings habe ich eine Lösung gefunden. Wenn ich die Files Sektion wie folgt ändere, funktioniert es:

Code: Alles auswählen

[Files_CreateUserFiles]
copy "%ScriptPath%\test.txt" "%CurrentProfileDir%\AppData\local\TestScript\"
Das ist nicht perfekt, aber es reicht mir erstmal. Ggf. findet Ihr ja noch eine Lösung dafür.

Grüße, Torsten
toddi
Beiträge: 12
Registriert: 17 Mai 2018, 07:24

Re: Solved: AllUserProfile in Files Sektion funktioniert nicht

Beitrag von toddi »

Und noch ein Nachtrag.

So funktioniert es auch:

Code: Alles auswählen

[Files_CreateUserFiles]
copy "%ScriptPath%\test.txt" "%CurrentProfileDir%$UserPath$"
Die Variable muss sich anscheinend explizit in der Files Sektion befinden.

Grüße, Torsten
Antworten