ODOTServer
asked on
Script to find install path of firefox
Creating this to copy the Mozilla.cfg and local-settings.js files to any machine that has firefox installed.
Basically needing a script to find the path firefox is installed, change the path to a variable and then copy two files to the Mozilla install directory. writing it as a batch file but if you have a powershell script that will work that would be fine too. This needs to be able to un on windows 7 machines. It will be applied to the computer group policy script setting.
This is what I have so far. I'm having a problem deleting the \firefox.exe from the end of the path. Its only pulling the path directly to the firefox.exe.
FOR /F "tokens=1,2* delims= " %%i in ('reg query "HKLM\Software\Clients\Sta rtMenuInte rnet\FIREF OX.EXE\she ll\open\co mmand" /s ^| find "Default"') do SET user_ffx_location=%%k
set %user_ffx_location%=%chang effx%
set _changeffx
set _result=%_\firefox.exe=%
%changeffx%=%userffx_locat ion%
copy \\fileshare\share\mozilla. cfg "%user_ffx_location%\mozil la.cfg"
copy \\fileshare\share\local-se ttings.js "%user_ffx_location%\pref\ local-sett ings.js"
)
)
Thanks.
Basically needing a script to find the path firefox is installed, change the path to a variable and then copy two files to the Mozilla install directory. writing it as a batch file but if you have a powershell script that will work that would be fine too. This needs to be able to un on windows 7 machines. It will be applied to the computer group policy script setting.
This is what I have so far. I'm having a problem deleting the \firefox.exe from the end of the path. Its only pulling the path directly to the firefox.exe.
FOR /F "tokens=1,2* delims= " %%i in ('reg query "HKLM\Software\Clients\Sta
set %user_ffx_location%=%chang
set _changeffx
set _result=%_\firefox.exe=%
%changeffx%=%userffx_locat
copy \\fileshare\share\mozilla.
copy \\fileshare\share\local-se
)
)
Thanks.
So your code would be:
for /f "tokens=1,2* delims= " %%i in ('reg query "HKLM\Software\Clients\StartMenuInternet\FIREFOX.EXE\shell\open\command" /s ^| find "Default"') do (
set user_ffx_location=%%~dpk
)
copy \\fileshare\share\mozilla.cfg "%user_ffx_location%mozilla.cfg"
copy \\fileshare\share\local-settings.js "%user_ffx_location%pref\local-settings.js"
~bp
ASKER
Great, thanks. Is there a way to end the script if it can't find the registry key? So it doesn't just error if firefox isn't installed?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked. Thanks!
Welcome, glad that was useful.
~bp
~bp
Open in new window
~bp