Jump to content

A comparison of methods...


Wombat
 Share

Recommended Posts

So I'm looking at creating a small script that writes a logbook. It will need to be able to determine if the client machine has either MS office Excel installed or if it has Libre Office installed and then from there use the appropriate functions. I have everything down, except the determining the installed software. I could check for an .exe,  a regkey, or the installed list... but I want to ask the community what you all think is the best solution(s) to best eliminate errors. What method is best advised, or should i use a combination of methods?

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

I'm still pretty much a rookie. But I'd probably go for the registry. Not exactly sure how to accomplish that. But if a program is installed my guess it would be in there. https://www.autoitscript.com/autoit3/docs/functions/RegRead.htm

Edited by markyrocks
Link to comment
Share on other sites

  • Moderators

I tend to favor a mix of approaches, just because I have seen the volume of crap that can be left behind in the registry should the person have had MS Office at one time and then uninstalled. You might combine a look in the registry's Uninstall key, a look under the Explorer key for a specific extension to see what it is set to open with (is .doc set to open with MSWord or the LibreOffice equiv. for example), and then I might do something like this to grab from WMI. You could easily change the msgbox into an "If MS Office Then..." statement:

$WMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2")
$aItems = $WMI.ExecQuery("SELECT * FROM Win32_Product")

For $element In $aItems
    MsgBox(0, "", $element.Name)
Next

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Did you know you can create excel spread sheets without excel installed?  You won't be able to view them, but just throwing that out there.  I have a sample in my sig, and pleanty more are out there.

So if you farm out work, as long as the end results of the logging are on a station with excel, there is no need to differentiate with what app to create the logging.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

 

I tend to favor a mix of approaches, just because I have seen the volume of crap that can be left behind in the registry should the person have had MS Office at one time and then uninstalled. You might combine a look in the registry's Uninstall key, a look under the Explorer key for a specific extension to see what it is set to open with (is .doc set to open with MSWord or the LibreOffice equiv. for example), and then I might do something like this to grab from WMI. You could easily change the msgbox into an "If MS Office Then..." statement:

$WMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2")
$aItems = $WMI.ExecQuery("SELECT * FROM Win32_Product")

For $element In $aItems
    MsgBox(0, "", $element.Name)
Next

 

This is a method worth attempting, but like you said there could be garbage left over in the registry. maybe a combination of the three is required

Did you know you can create excel spread sheets without excel installed?  You won't be able to view them, but just throwing that out there.  I have a sample in my sig, and pleanty more are out there.

So if you farm out work, as long as the end results of the logging are on a station with excel, there is no need to differentiate with what app to create the logging.

 

I have been watching that thread... I would actually prefer this method. Creating the raw xml that would then be readable/editable via excel/libre. This would keep me from having to install libre on a HUGE amount of client machines...

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

  • Moderators

A combination, probably 2 of the 3, is what I was suggesting. All 3 may be overkill.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I'd use something even simpler, at least for me. Try to use _ExcelNew and see if you get an error, if you do, then it's probably not installed or can't be used by the current user, then try it with whatever Libre/OpenOffice functions that are equivalent and see if that succeeds.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'd use something even simpler, at least for me. Try to use _ExcelNew and see if you get an error, if you do, then it's probably not installed or can't be used by the current user, then try it with whatever Libre/OpenOffice functions that are equivalent and see if that succeeds.

 

That's some Occams Razor Shtuff

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

I looked at it like a FileExists feature, check to see if you can use it, if you can't it's not there. Try it with the next possible program, and if that doesn't work, it's probably not there either. Then if neither are installed, use the direct to file udf mentioned above. It would only require a few nested If statements to get to the working functionality.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...