Discussion:
newbie looking for file location
(too old to reply)
TD
2009-11-05 21:02:46 UTC
Permalink
I am trying to write a script that I can launch from a login bat file that
looks for a location of a program. Once the file location is found I want to
take that location and dumps it to a reg key. Here's an example

We want to set a default photo viewer on our network and would like to use
Microsoft Office Picture Manager. I have found that this file can be located
in different locations. On log in I would like the script to check basically
3 locations (c:\program files\Microsoft office\Office11, c:\program
files\Microsoft office\Office12, and c:\program files\Microsoft
office\ART\Office12) and then copy the path that is finds the OIS.exe file
to a key in the registry.

Can someone point me to the easiest cleanest way to do this.


TIA
Pegasus [MVP]
2009-11-05 21:18:42 UTC
Permalink
Post by TD
I am trying to write a script that I can launch from a login bat file that
looks for a location of a program. Once the file location is found I want
to take that location and dumps it to a reg key. Here's an example
We want to set a default photo viewer on our network and would like to use
Microsoft Office Picture Manager. I have found that this file can be
located in different locations. On log in I would like the script to check
basically 3 locations (c:\program files\Microsoft office\Office11,
c:\program files\Microsoft office\Office12, and c:\program files\Microsoft
office\ART\Office12) and then copy the path that is finds the OIS.exe file
to a key in the registry.
Can someone point me to the easiest cleanest way to do this.
TIA
To see if a file exists, use the oFSO.FileExists method of the File System
Object. You will find the method fully explained (with an example!) in
script56.chm, a help file that you can (and should!) download from the
Microsoft site.

To insert a value into the registry, have a look here:
http://blogs.technet.com/heyscriptingguy/archive/2006/11/16/how-can-i-create-a-new-registry-key.aspx.
To download the whole Scripting Guy file (highly recommended!), look here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=5f5e0bda-923a-4744-8289-afb73f6a5ed8&displaylang=en.

And if you want a very easy method to do the job, use a batch file. It has a
"if exist FileName" command and the tool reg.exe lets you create a new
registry key.
jford
2009-11-09 14:04:06 UTC
Permalink
It works...

<batch>
@echo off

set loc1="C:\Program Files\Microsoft Office\Office11\OIS.exe"
set loc2="C:\Program Files\Microsoft Office\Office12\OIS.exe"
set loc3="C:\program files\Microsoft Office\ART\Office12\OIS.exe"

if exist %loc1% (
call :regadd %loc1%
)
if exist %loc2% (
call :regadd %loc2%
)
if exist %loc3% (
call :regadd %loc3%
)
goto end
:regadd
reg add <keyname> /v <valuename> /d %1
:end
</batch>
Post by TD
I am trying to write a script that I can launch from a login bat file that
looks for a location of a program. Once the file location is found I want to
take that location and dumps it to a reg key. Here's an example
We want to set a default photo viewer on our network and would like to use
Microsoft Office Picture Manager. I have found that this file can be located
in different locations. On log in I would like the script to check basically
3 locations (c:\program files\Microsoft office\Office11, c:\program
files\Microsoft office\Office12, and c:\program files\Microsoft
office\ART\Office12) and then copy the path that is finds the OIS.exe file
to a key in the registry.
Can someone point me to the easiest cleanest way to do this.
TIA
Loading...