Seite 1 von 1
[OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 20 Nov 2015, 09:40
von nicolaslebrun
Hello,
We're working at the moment on profiling Firefox...
We have the following line in our code
Code: Alles auswählen
[PatchTextFile_Set_Mozilla_pref_Pref_chaque_demarrage]
; Page de demarrage par defaut
Set_Mozilla_Pref ("user_pref","browser.startup.homepage", "$WebStartPage$" )
but the variable is not interpreted...
We tried
Code: Alles auswählen
Set_Mozilla_Pref ("user_pref","browser.startup.homepage", $WebStartPage$ )
and
Code: Alles auswählen
Set_Mozilla_Pref ("user_pref","browser.startup.homepage", '"'+$WebStartPage$+'"' )
but it's worst...
An y idea to pass a variable to a section PatchTextFile ?
Thks,
Regards,
Nico
Re: [OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 20 Nov 2015, 10:25
von holgerv
Hi!
Code: Alles auswählen
Set_Mozilla_Pref ("user_pref","browser.startup.homepage", "$WebStartPage$"
Your use of the variable seems to be correct:
https://download.uib.de/opsi4.0/doc/htm ... n-sections
Maybe you didn't define (DefVar) or set (Set) the variable correctly?
Re: [OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 21 Nov 2015, 14:44
von nicolaslebrun
Hi Holgerv,
Thanks for your reply, but the variable is correctly set...
It's a productproperty we define this way
Code: Alles auswählen
DefVar $WebStartPage$
Set $WebStartPage$ = GetProductProperty("WebStartPage","https://netocentre.fr/")
For debug, if we make
It's good.
I'm really wondering if it is possible to pass a variable to a PatchTextFile section...
Regards,
Nico
Re: [OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 23 Nov 2015, 15:19
von wolfbardo
Please post / check the complete script and log
regards,
Bardo Wolf
Re: [OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 26 Nov 2015, 11:25
von nicolaslebrun
Hi Bardo
Here it is !
Code: Alles auswählen
(15289) [5] [nov. 26 11:09:25:418] [opsi-firefox] getValue("installationstate", getProductMap) = "installed" <<< result true
(15290) [5] [nov. 26 11:09:25:418] [opsi-firefox] not(getValue("installationstate", getProductMap) = "installed") <<< result false
(15291) [6] [nov. 26 11:09:25:418] [opsi-firefox] Then
(15292) [6] [nov. 26 11:09:25:418] [opsi-firefox] EndIf
(15293) [6] [nov. 26 11:09:25:418] [opsi-firefox] If
(15294) [5] [nov. 26 11:09:25:461] [opsi-firefox] scriptWasExecutedBefore <<< result true
(15295) [6] [nov. 26 11:09:25:461] [opsi-firefox] Then
(15296) [5] [nov. 26 11:09:25:461] [opsi-firefox] comment: Execution des taches a chaque login
(15297) [5] [nov. 26 11:09:25:461] [opsi-firefox] message Execution des taches a chaque login
(15298) [5] [nov. 26 11:09:25:464] [opsi-firefox]
(15299) [5] [nov. 26 11:09:25:464] [opsi-firefox] Execution of PatchTextFile_Set_Mozilla_pref_Pref_chaque_demarrage
(15300) [6] [nov. 26 11:09:25:464] [opsi-firefox]
(15301) [6] [nov. 26 11:09:25:464] [opsi-firefox] Patching: C:\Users\gip.prof\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\prefs.js
(15302) [5] [nov. 26 11:09:25:464] [opsi-firefox] FILE C:\Users\gip.prof\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\prefs.js
(15303) [6] [nov. 26 11:09:25:466] [opsi-firefox] Item Pointer set to Top (before first line)
(15304) [6] [nov. 26 11:09:25:467] [opsi-firefox] Item no. 0 is starting with 'user_pref("browser.startup.homepage"'
(15305) [6] [nov. 26 11:09:25:467] [opsi-firefox] Item Pointer set to 0
(15306) [6] [nov. 26 11:09:25:467] [opsi-firefox] Deleted item no. 0: user_pref("browser.startup.homepage", "$WebStartPage$" );
(15307) [6] [nov. 26 11:09:25:467] [opsi-firefox] No item found starting with 'user_pref("browser.startup.homepage"'
(15308) [6] [nov. 26 11:09:25:467] [opsi-firefox] Item Pointer set to Top (before first line)
(15309) [6] [nov. 26 11:09:25:467] [opsi-firefox] Inserted item 'user_pref("browser.startup.homepage", "$WebStartPage$" );' at position 0
(15310) [6] [nov. 26 11:09:25:467] [opsi-firefox] C:\Users\gip.prof\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\prefs.js saved back with 8 Bit system encoding
(15311) [6] [nov. 26 11:09:25:468] [opsi-firefox] Else
(15312) [6] [nov. 26 11:09:25:468] [opsi-firefox] EndIf
(15313) [1] [nov. 26 11:09:25:468] [opsi-firefox] ___________________
(15314) [1] [nov. 26 11:09:25:468] [opsi-firefox] script finished
(15315) [1] [nov. 26 11:09:25:468] [opsi-firefox] 0 errors
(15316) [1] [nov. 26 11:09:25:468] [opsi-firefox] 0 warnings
(15317) [1] [nov. 26 11:09:25:468] [opsi-firefox]
(15318) [1] [nov. 26 11:09:25:468] [opsi-firefox] Executed login script for : opsi-firefox Version: 42.0.0.5780-88
(15319) [1] [nov. 26 11:09:25:468] [opsi-firefox]
And the useful parts of code
Code: Alles auswählen
DefVar $WebStartPage$
Set $WebStartPage$ = GetProductProperty("WebStartPage","https://netocentre.fr/")
PatchTextFile_Set_Mozilla_pref_Pref_chaque_demarrage "%UserProfileDir%\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\prefs.js"
[PatchTextFile_Set_Mozilla_pref_Pref_chaque_demarrage]
; Page de demarrage par defaut
Set_Mozilla_Pref ("user_pref","browser.startup.homepage", "$WebStartPage$" )
An idea ?
Thanks,
Regards,
Nico
Re: [OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 03 Dez 2015, 13:09
von wolfbardo
Hi Nico,
the script is doing what is scripted, patching
Code: Alles auswählen
C:\Users\gip.prof\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\prefs.js
but perhaps not doing what you want do...
I dont know where your prefs.js should be.
Maybe an alternative is
- have a deeper look in the opsi.-winst-manuals and opsi extension User Profile Management
- working with a
see
http://kb.mozillazine.org/Locking_preferences
- test our Update subscription for the opsi standard packets ...
regards,
bardo wolf
Re: [OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 03 Dez 2015, 13:41
von nicolaslebrun
Thanks for your reply, Bardo...
May be the way we wan't to manage Firefox profile is not the best one, and i'll see if we can do it another way...
But i disagree with
the script is doing what is scripted, patching
It does patch the file prefs.js...
But it patches it with the NAME of the variable instead of the VALUE of the variable.
The patched prefs.js file contains
Code: Alles auswählen
user_pref("browser.startup.homepage", "$WebStartPage$" );
but I want
Code: Alles auswählen
user_pref("browser.startup.homepage", "https://netocentre.fr" );
as the value of $WebStartPage$ is "
https://netocentre.fr"
What am I missing ?
Regards
Nico
Re: [OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 03 Dez 2015, 14:30
von wolfbardo
mmh,
works for me:
Code: Alles auswählen
[Actions]
comment "Actions section"
[ProfileActions]
DefVar $WebStartPage$
Set $WebStartPage$ = GetProductProperty("WebStartPage","https://netocentre.fr/")
PatchTextFile_Set_Mozilla_pref_Pref_chaque_demarrage "%UserProfileDir%\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\prefs.js"
Registry loadunicodetextfile("%SCRIPTPATH%\opsi.org.reg") /regedit /32bit
[PatchTextFile_Set_Mozilla_pref_Pref_chaque_demarrage]
; Page de demarrage par defaut
Set_Mozilla_Pref ("user_pref","browser.startup.homepage", "$WebStartPage$" )
...
Code: Alles auswählen
[4] [Dez 03 14:20:32:389] [test1] Property not existing in GetProductProperty - using default
[6] [Dez 03 14:20:32:389] [test1] The value of the variable "$WebStartPage$" is now: "https://netocentre.fr/"
[5] [Dez 03 14:20:32:389] [test1]
[5] [Dez 03 14:20:32:389] [test1] Execution of PatchTextFile_Set_Mozilla_pref_Pref_chaque_demarrage
[6] [Dez 03 14:20:32:389] [test1]
[6] [Dez 03 14:20:32:389] [test1] Patching: C:\Users\wolf\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\prefs.js
[5] [Dez 03 14:20:32:389] [test1] FILE C:\Users\wolf\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\prefs.js
[6] [Dez 03 14:20:32:390] [test1] Info: This file does not exist and will be created
[4] [Dez 03 14:20:32:392] [test1] Warning: Directory C:\Users\wolf\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\ did not exist und was created
[6] [Dez 03 14:20:32:392] [test1] Item Pointer set to Top (before first line)
[6] [Dez 03 14:20:32:393] [test1] No item found starting with 'user_pref("browser.startup.homepage"'
[6] [Dez 03 14:20:32:393] [test1] Added item 'user_pref("browser.startup.homepage", "https://netocentre.fr/" );'
and File
Code: Alles auswählen
C:\Users\wolf\AppData\Roaming\Mozilla\Firefox\Profiles\Defaut\prefs.js
exists now
Code: Alles auswählen
type prefs.js
user_pref("browser.startup.homepage", "https://netocentre.fr/" );
hope, that helps,
regards,
bardo wolf
Re: [OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 03 Dez 2015, 15:43
von nicolaslebrun
So, there is a mistake in my code.
I'll double check and come back...
Thanks for the help, Bardo
Regards,
Nico
Re: [OPSI4.0.6][WINST] Set_Mozilla_Pref with variable doesn't work ?
Verfasst: 15 Dez 2015, 18:32
von SisterOfMercy
Don't forget that the browser.startup.homepage needs a different syntax:
Code: Alles auswählen
defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://www.dilbert.com");
This is a snippet from a firefox prefs.js file, so for OPSI, and your case it will be like this:
Code: Alles auswählen
user_pref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=https://netocentre.fr" );
Reference:
https://mike.kaply.com/2012/08/29/setti ... utoconfig/