checking if program is installing using python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • GujuBoy

    checking if program is installing using python

    i want to check to see if a certain program is installed on my windows
    box using python. how can i do that...(ie, i want to see if "word" is
    installed)

    please help

  • wittempj@hotmail.com

    #2
    Re: checking if program is installing using python

    does this help?


    Comment

    • Trent Mick

      #3
      Re: checking if program is installing using python

      [wittempj@hotmai l.com wrote][color=blue]
      > does this help?
      > http://aspn.activestate.com/ASPN/Coo...n/Recipe/52224[/color]

      There is the "which" module that I wrote that does this a little more
      robustly:


      However, I didn't see the original posting for this thread so I'm not
      sure if this is what is being looked for.

      Cheers,
      Trent

      --
      Trent Mick
      TrentM@ActiveSt ate.com

      Comment

      • Peter Hansen

        #4
        Re: checking if program is installing using python

        wittempj@hotmai l.com wrote:[color=blue]
        > does this help?
        > http://aspn.activestate.com/ASPN/Coo...n/Recipe/52224[/color]

        It's very rare that a program like Word is installed
        in the PATH, so it's unlikely this helps.

        Generally you would need to look in the registry, or
        perhaps use os.popen() to parse the output of executing
        the command "assoc .doc", to do what is required.

        It might help for the OP to describe more about what
        he plans to do with the information, since there might
        be simpler/better approaches.

        -Peter

        Comment

        • alex23

          #5
          Re: checking if program is installing using python

          GujuBoy wrote:[color=blue]
          > i want to check to see if a certain program is installed on my
          > windows box using python. how can i do that...(ie, i want to
          > see if "word" is installed)[/color]

          This won't help you if you're after an off-the-cuff search for
          installed apps, but if you need to determine the existence of a known
          application in order to do something specific, this might be of some
          use.

          First, use the registry to determine the install location of the app.
          (You might like to check out the following recipe, which deals with
          accessing the registry via Python:
          http://aspn.activestate.com/ASPN/Coo...n/Recipe/66011)

          For example, to find the location where MS Office 2003 is installed,
          you need to check the registry key
          "HKEY_LOCAL_MAC HINE\SOFTWARE\M icrosoft\Office \11.0\Common\In stallRoot"
          which has two values, the 2nd of which, "Path" is set to "C:\Program
          Files\Microsoft Office\OFFICE11 \" on my work PC.

          Once you have the location, you can just use
          os.path.exists( path-from-reg + "\Word.exe" ) to check that it's actually
          there.

          In some cases, such as with MSOffice, the key you need to refer to will
          depend on the version installed. As mentioned, the regkey above is for
          MS Office 2003, which is recorded in the registry as version 11.0. If
          you're only concerned that they have an application installed without
          caring what version they're using, you'll need to check for several
          keys to find the information you're looking for. (Office XP is 10.0,
          Office 2K is 9.0, etc) Office is pretty consistent about this between
          versions but other applications (such as the godawful virus checker we
          use here) can't be counted on being quite as helpful.

          Also worth noting if you're actually interested in testing for the
          existence of Office apps is that each member of the Office suite can
          have its own install location. So if you're only checking for Word, the
          key
          "HKEY_LOCAL_MAC HINE\SOFTWARE\M icrosoft\Office \11.0\Word\Inst allRoot"
          would be more relevant than the common install area given above.

          Hopefully something in this somewhere will help :)

          -alex23

          Comment

          Working...