a06lp Posted July 28, 2005 Posted July 28, 2005 Hi all,I'm editing my cleanup.cmd file, and there's something I need to do.I need a way to say "If Firefox is installed, then run the following 3 lines of code".Then 3 lines of code are:REM Mozilla Firefox (Remove IE Shortcuts) DEL "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Launch Internet Explorer Browser.lnk" REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu /v "{871C5380-42A0-1069-A2EA-08002B30309D}" /t REG_DWORD /d 1 /f REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\HideDesktopIcons\NewStartPanel /v "{871C5380-42A0-1069-A2EA-08002B30309D}" /t REG_DWORD /d 1 /fBut these lines should ONLY run, IF firefox was installed.Also, I need the way to check for firefox to be path-indifferent - meaning, it doesn't matter where firefox is installed to.How can I do this?
Yzöwl Posted July 28, 2005 Posted July 28, 2005 (edited) @ a06lp, this should do it!@echo off&setlocal enableextensionsfor /f "delims=" %%a in ('reg query "HKLM\SOFTWARE\Mozilla\Mozilla Firefox" /s^|findstr "\\Main$"^2^>nul') do ( if errorlevel 0 for /f "tokens=1,3* delims= " %%b in ('reg query "%%a"^|find "Install Directory"^2^>nul') do ( if errorlevel 0 set ffdir="%%~c" ))if defined ffdir ( :: Mozilla Firefox (Remove IE Shortcuts) echo/del /q "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Launch Internet Explorer Browser.lnk" echo/reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu /v "{871C5380-42A0-1069-A2EA-08002B30309D}" /t REG_DWORD /d 1 /f echo/reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\HideDesktopIcons\NewStartPanel /v "{871C5380-42A0-1069-A2EA-08002B30309D}" /t REG_DWORD /d 1 /f)pause&endlocal&goto :eofJust remove the stuff in red once you have verified it works.<Edit>Just looking back at my code, I have noticed that, due to the way the site software works, I need to mention something.make sure when you paste the information into your file, that:delims=<Tab>notdelims=<Space><Edit> Edited July 28, 2005 by Yzöwl
a06lp Posted July 29, 2005 Author Posted July 29, 2005 Just looking back at my code, I have noticed that, due to the way the site software works, I need to mention something.make sure when you paste the information into your file, that:delims=<Tab>notdelims=<Space>Hmm, why is this? Are you sure it won't work? It seemed to be working when I copied and pasted the original code into my cleanup.cmd file...
Yzöwl Posted July 29, 2005 Posted July 29, 2005 (edited) The code will still do it's job in that it will still run the appropriate commands, only if the application is installed.However, the content of %ffdir% will be incorrect. If you use delims=<Tab>, then %ffdir% will also contain the installation path for the application, which you would be able to utilise further in your batch file if you felt the need.<Edit>Oh and thank you usually works better for me</Edit> Edited July 29, 2005 by Yzöwl
a06lp Posted July 29, 2005 Author Posted July 29, 2005 my most sincere apoligies for not saying this first:Thank You!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now