Variablenauflösung klappt nicht bei ChangeDirectory

Antworten
feltel
Beiträge: 222
Registriert: 09 Dez 2014, 07:22

Variablenauflösung klappt nicht bei ChangeDirectory

Beitrag von feltel »

Zu allererst euch allen und natürlich besonders dem OPSI-Team ein gesundes neues Jahr und besonders viel Schaffenskraft. :-)

Ich habe mit ChangeDirectory in einem meiner OPSI-Scripte ein kleines Problem. Scheinbar wird, wenn ChangeDirectory mit einer Variable aufgerufen wird, diese nicht aufgelöst. Andere Aktionen und Befehle im gleichen Script mit der gleichen unveränderten Variable klappen ohne Probleme.

Das OPSI-Script sieht (partiell) so aus:

Code: Alles auswählen

DefVar $installation_random_localpath$
Set $installation_random_localpath$ = "%opsiTmpDir%\M365Offfice_" + RandomStrWithParameters("10","5","0","5","0")

DosInAnIcon_Mount_Installsource
Files_Copy_Installer
ChangeDirectory "$installation_random_localpath$"
Winbatch_setup
Sub_check_exitcode
DosInAnIcon_Unmount_Installsource
Files_Delete_Installer

[Files_Copy_Installer]
copy -s $installation_source$\Office\*.* "$installation_random_localpath$\Office"
copy -s $installation_source$\setup.exe "$installation_random_localpath$"
copy -s "$installation_source$\$installation_XMLfile$" "$installation_random_localpath$"
....
Wenn das Script läuft, dann sieht das im Log (mal exemplarisch für die beiden o.g. Funktionen) so aus:

Code: Alles auswählen

(104)     [6] [2021-01-04 14:14:40.941] [microsoft-microsoft365] Set  $installation_random_localpath$ = "c:\opsi.org\tmp\M365Offfice_" + RandomStrWithParameters("10","5","0","5","0")
(105)     [6] [2021-01-04 14:14:40.941] [microsoft-microsoft365]   The value of the variable "$installation_random_localpath$" is now: "c:\opsi.org\tmp\M365Offfice_o44r9px13o"
...
(137)     [5] [2021-01-04 14:14:41.362] [microsoft-microsoft365]   Execution of: Files_Copy_Installer
(138)     [5] [2021-01-04 14:14:41.362] [microsoft-microsoft365]   
(139)     [7] [2021-01-04 14:14:41.372] [microsoft-microsoft365]     copy -s \\FILESERVER\m365$\Office\*.* "c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office"
(140)     [7] [2021-01-04 14:14:41.372] [microsoft-microsoft365]     copy
(141)     [6] [2021-01-04 14:14:41.373] [microsoft-microsoft365]         path c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office created
(142)     [6] [2021-01-04 14:14:41.418] [microsoft-microsoft365]     Copying  \\FILESERVER\m365$\Office\*.* -----> c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office
(143)     [6] [2021-01-04 14:14:41.418] [microsoft-microsoft365]       8 File(s) found
(144)     [6] [2021-01-04 14:14:41.426] [microsoft-microsoft365]       No (non-directory) file with mask  \\FILESERVER\m365$\Office\*.*  found
(145)     [6] [2021-01-04 14:14:41.428] [microsoft-microsoft365]       Source \\FILESERVER\m365$\Office\Data\v64.cab
(146)     [6] [2021-01-04 14:14:41.466] [microsoft-microsoft365]         \\FILESERVER\m365$\Office\Data\v64.cab copied to c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office\Data\
(147)     [6] [2021-01-04 14:14:41.468] [microsoft-microsoft365]       Source \\FILESERVER\m365$\Office\Data\v64_16.0.12527.21416.cab
(148)     [6] [2021-01-04 14:14:41.497] [microsoft-microsoft365]         \\FILESERVER\m365$\Office\Data\v64_16.0.12527.21416.cab copied to c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office\Data\
(149)     [6] [2021-01-04 14:14:41.502] [microsoft-microsoft365]       Source \\FILESERVER\m365$\Office\Data\16.0.12527.21416\i640.cab
(150)     [6] [2021-01-04 14:14:44.060] [microsoft-microsoft365]         \\FILESERVER\m365$\Office\Data\16.0.12527.21416\i640.cab copied to c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office\Data\16.0.12527.21416\
(151)     [6] [2021-01-04 14:14:44.078] [microsoft-microsoft365]       Source \\srv001.ad.docemus.de\m365$\Office\Data\16.0.12527.21416\i641031.cab
(152)     [6] [2021-01-04 14:14:44.110] [microsoft-microsoft365]         \\FILESERVER\m365$\Office\Data\16.0.12527.21416\i641031.cab copied to c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office\Data\16.0.12527.21416\
(153)     [6] [2021-01-04 14:14:44.110] [microsoft-microsoft365]       Source \\FILESERVER\m365$\Office\Data\16.0.12527.21416\s640.cab
(154)     [6] [2021-01-04 14:14:44.503] [microsoft-microsoft365]         \\FILESERVER\m365$\Office\Data\16.0.12527.21416\s640.cab copied to c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office\Data\16.0.12527.21416\
(155)     [6] [2021-01-04 14:14:44.521] [microsoft-microsoft365]       Source \\srv001.ad.docemus.de\m365$\Office\Data\16.0.12527.21416\s641031.cab
(156)     [6] [2021-01-04 14:14:44.670] [microsoft-microsoft365]         \\FILESERVER\m365$\Office\Data\16.0.12527.21416\s641031.cab copied to c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office\Data\16.0.12527.21416\
(157)     [6] [2021-01-04 14:14:44.670] [microsoft-microsoft365]       Source \\srv001.ad.docemus.de\m365$\Office\Data\16.0.12527.21416\stream.x64.de-de.dat
(158)     [6] [2021-01-04 14:15:17.914] [microsoft-microsoft365]         \\FILESERVER\m365$\Office\Data\16.0.12527.21416\stream.x64.de-de.dat copied to c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office\Data\16.0.12527.21416\
(159)     [6] [2021-01-04 14:15:17.944] [microsoft-microsoft365]       Source \\srv001.ad.docemus.de\m365$\Office\Data\16.0.12527.21416\stream.x64.x-none.dat
(160)     [6] [2021-01-04 14:18:42.441] [microsoft-microsoft365]         \\FILESERVER\m365$\Office\Data\16.0.12527.21416\stream.x64.x-none.dat copied to c:\opsi.org\tmp\M365Offfice_o44r9px13o\Office\Data\16.0.12527.21416\
(161)     [6] [2021-01-04 14:18:42.485] [microsoft-microsoft365]       8 File(s) treated
...
(190)     [5] [2021-01-04 14:18:43.745] [microsoft-microsoft365]   Finished of: Files_Copy_Installer
(191)     [3] [2021-01-04 14:18:43.746] [microsoft-microsoft365]   Error at ChangeDirectory: C:\WINDOWS\system32\$installation_random_localpath$ is not a directory
(192)     [5] [2021-01-04 14:18:43.746] [microsoft-microsoft365]   Execution of: Winbatch_setup
(193)     [5] [2021-01-04 14:18:43.746] [microsoft-microsoft365]
Ich kann also nach $installation_random_localpath$ kopieren, das Setup starten und erfolgreich durchlaufen lassen, jedoch mittendrin kein "CD" in das Verzeichnis machen. Mach oder verstehe ich was falsch oder ist das evtl. ein Bug in dieser Funktion? Das Script läuft auch ohne, aber ich weiß nicht, wie oft ich das Paket schon habe umbauen müssen, weil Microsoft mal wieder was am Laufzeitverhalten des Installers geändert hat. Ursprünglich ließ sich Office 365 direkt vom Netzwerkshare installieren, aber da steigt seit ein paar Versionen der Installer mit einer wilden Fehlermeldung aus.
Benutzeravatar
wolfbardo
uib-Team
Beiträge: 1354
Registriert: 01 Jul 2008, 12:10

Re: Variablenauflösung klappt nicht bei ChangeDirectory

Beitrag von wolfbardo »

Vgl. getting-started

"Elementare Befehle für primäre Sektionen
...
WichtigStringvariablen werden in primären und sekundären Sektionen unterschiedlich behandelt. "

Mit

Code: Alles auswählen

ChangeDirectory $installation_random_localpath$
sollte das klappen.

Gruss
Bardo Wolf


OPSICONF 2024
https://opsi.org/en/opsiconf/

Basisworkshop Mainz :

17. - 20. 06. 2024


opsi support - uib gmbh
For productive opsi installations we recommend maintainance + support contracts which are the base of opsi development.

http://www.uib.de
feltel
Beiträge: 222
Registriert: 09 Dez 2014, 07:22

Re: Variablenauflösung klappt nicht bei ChangeDirectory

Beitrag von feltel »

Ah vielen Dank. An sowas hab ich nun wirklich nicht gedacht. Vielleicht sollte man trotz das man OPSI schon ein paar Jahre nutzt, ab und an doch noch in das Getting-Started schauen. Im Script-Manual hab ich gesucht und aber nichts auffälliges gefunden.
Antworten