MSFN Forum: Conditional Cleanup Items? - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Conditional Cleanup Items? IF (installed) THEN (cleanup)? Rate Topic: -----

#1 User is offline   a06lp 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 976
  • Joined: 19-August 04

Posted 28 July 2005 - 07:48 AM

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 /f


But 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?


#2 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 28 July 2005 - 08:35 AM

@ a06lp, this should do it!

Quote

@echo off&setlocal enableextensions
for /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 :eof
Just 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>
    not
    delims=<Space>
<Edit>

This post has been edited by Yzöwl: 28 July 2005 - 10:15 AM


#3 User is offline   Sonic 

  • Sonic
  • Group: Patrons
  • Posts: 1,600
  • Joined: 04-December 03

Posted 28 July 2005 - 12:05 PM

yes it's the solution :)

#4 User is offline   a06lp 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 976
  • Joined: 19-August 04

Posted 28 July 2005 - 10:04 PM

Yzöwl, on Jul 28 2005, 10:35 AM, said:

Just looking back at my code, I have noticed that, due to the way the site software works, I need to mention something.[list]make sure when you paste the information into your file, that:
delims=<Tab>
not
delims=<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...

#5 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 29 July 2005 - 04:08 AM

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>

This post has been edited by Yzöwl: 29 July 2005 - 04:10 AM


#6 User is offline   a06lp 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 976
  • Joined: 19-August 04

Posted 29 July 2005 - 06:43 AM

my most sincere apoligies for not saying this first:
Thank You!

:thumbup :thumbup :thumbup

#7 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 29 July 2005 - 12:05 PM

I was only joking, but thanks anyhow…

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy