| 1. |
Solve : Set variable equal to part of a path? |
|
Answer» Squashman, thanks for the perspective. You made a good point. Salmon Trout I SUPPOSE I could have DONE that. I guess, like anything there are many different ways to arrive at the same destination. I'm not sure I if I even thought of doing it that way though. I recall getting hung up on how to set parts of the file path equal to different variables. But after Salmon Trout mentioned that his Windows registry didn't include the InstallRoot key I became concerned - every machine I tested on had the key but when I first wrote this script it ran well on every machine I tested it on. This is all I have under HKLM\Software\Microsoft\Office - one key: Outlook Quote from: powlaz on January 23, 2014, 11:43:37 AM because I often write out my commands line by line and then work to shorten them to as few lines as possible. I noticed your shortened the code I gave you. There are often bits of code that don't seem to do anything when you remove them, but they fix issues when the code is used on other machines.Quote from: powlaz on January 23, 2014, 12:08:35 PM I wonder if you have the key under the WOW6432Node key. Yes. That is where it is stored. I have 32 bit Office 2003 on 64 bit Windows 7. Foxidrive, I did wonder why you had included those couple of extra find statements. What did you see that I didn't? The statement I said I was going to use last time I posted yielded mixed results. When I first composed this reply over a week ago I was planning on changing to using a directory search like Salmon Trout suggested - but it ran too slowly. Then I decided to use the reg query that we had discussed and that's how I was going to leave it. However, I was drawn into another project that required me to find the install directory for Adobe Reader. A slight tweak to the "ftype" statement proved to provide much better/faster results. So I modified it for my Office search: Code: [Select]For /f "tokens=2 delims==" %%a in ('ftype ^|find /I "C:\Program" ^|findstr /I "excel.exe"')DO SET Office=%%a Set OfficePATH=%Office:~1,-10% This returns results the fastest and eliminates the erroneous results I was getting earlier. Again, I really appreciate all the replies here. I learned a lot. MJ |
|