[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

MS Office Windows File Associations via command line

Posted on 2010-08-17
10
Medium Priority
?
2,196 Views
Last Modified: 2012-08-13
Hello guys;

I need to create a batch file that will help me associate all MS Word extensions with MS Office word.exe

.doc
.dochtml
.docm
.docx
.docxml
.dot
.dothtml
.rtf
.wbk
.dotm
.dotx

We have environment that dose not allow us to associate the files automatically so we have to do it manually and not via registry in other words it must be a batch file.

 Can someone drop me some examples (step by step) on how I can accomplish that ? Thanks

0
Comment
Question by:atigris
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 2

Expert Comment

by:Beghemot
ID: 33461441
Please clarify the info about your environment...

So the batch file can not include commands that modify the registry?
or
Your access to the registry editing tools is disabled via policy and you need a script that can bypass the policy?

How do you normally "manually" create the associations?
0
 
LVL 2

Expert Comment

by:uscshaggy
ID: 33461455
You can use the 'assoc' command for this.  You should check on a system that has the file associations that you want to confirm the proper commands.  You can do this by running 'assoc .doc' on that system and seeing what is returned.  On my XP box with Office 2003 and my 7 box with Office 2007 it shows:  .doc=Word.Document.8

Do this for each file type to get all the appropriate associations, and then create your script to set those same values.

So your batch file will simply be:


@echo off
assoc .doc=Word.Document.8
assoc .dochtml=wordhtmlfile
assoc .docm=Word.DocumentMacroEnabled.12
assoc .docx=Word.Document.12

Open in new window

0
 
LVL 2

Author Comment

by:atigris
ID: 33465806
yes, we manually create them for each user by right clicking on a document let us say .doc  then choose "open with" and select the appropriate app in our case "MS Word"

So that means yes there will edit the registry. we want this process to be automated so one click it will assign all extensions to it's appropriate applications.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 2

Expert Comment

by:Beghemot
ID: 33466567
uscshaggy's method is a great one. The assoc command can batch the changes you need.

http://support.microsoft.com/kb/323526
0
 
LVL 2

Author Comment

by:atigris
ID: 33466693
Ok thanks guys but I don't know from where Word.Document.8, wordhtmlfile , Word.DocumentMacroEnabled.12 ...etc is coming from.

How to find these values as I have to do it for all MS office sweet and PDF

@echo off
assoc .doc=Word.Document.8
assoc .dochtml=wordhtmlfile
assoc .docm=Word.DocumentMacroEnabled.12
assoc .docx=Word.Document.12
0
 
LVL 2

Author Comment

by:atigris
ID: 33466739
I tried ASSOCIATE .xls     "%SystemRoot%\Program Files\Microsoft Office\Office12\EXCEL.exe" /q /f

it will add it with no errors but when I try to click on the application it will not allow it to open and instead it shows "open with" to select the appropriate application.  

Can someone advice ?

Thanks
0
 
LVL 2

Expert Comment

by:Beghemot
ID: 33466998
Ok at a command prompt at at machine where you manually loaded the associations type assoc >assoc.txt

This will send the output of the assoc commant to a textfile.  It generates a list of all the file associations on the machine.  You shouldn't have to point it at an executable, just at a preregistered file type.

For excel it would look something like this:


assoc .xls=Excel.Sheet.8

Open in new window

0
 
LVL 2

Author Comment

by:atigris
ID: 33467295
Ok, My application is installed in isolation environment in other words .xls=Excel.Sheet.8 will now show up when I  type assoc in the command prompt  because the application is not installed on the system.

Is there anyway I can register this with the registry via command line ?
0
 
LVL 2

Expert Comment

by:uscshaggy
ID: 33467555
Can you clarify your last comment?  Are you saying .xls=Excel.Sheet.8 does or does not show up when you type 'assoc'?

It shouldn't show up until you run the command to create the association.  Once you have run all the commands via batch script, then they should show up in the 'assoc' output and open with the appropriate application assuming it is installed.
0
 
LVL 2

Accepted Solution

by:
plymelk earned 2000 total points
ID: 33477181
I believe that you are missing the ftype command.
The ftype command allows you to assign an action to the File Type.  This is an extra layer that allows each application to define their open action.  (From the registry, move actions are available).
 
 
C:\WINDOWS\system32>assoc .xls
.xls=Excel.Sheet.8
C:\WINDOWS\system32>ftype Excel.Sheet.8
Excel.Sheet.8="C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /e
C:\WINDOWS\system32>

So your script should look like the attached code (Snippet ID=941675).
 

@echo off
ftype Word.Document.8="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE" /n /dde
ftype wordhtmlfile="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE"
ftype Word.DocumentMacroEnabled.12="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE" /n /dde
ftype Word.Document.12="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE" /n /dde
ftype Word.Template.8="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE" /n /dde
ftype wordhtmltemplate="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE"
ftype Word.RTF.8="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE" /n /dde
ftype Word.Backup.8="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE" /n /dde
ftype Word.TemplateMacroEnabled.12="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE" /n /dde
ftype Word.Template.12="C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE" /n /dde

rem On the source system, wordxmlfile was undefined for ftype

assoc .doc=Word.Document.8
assoc .dochtml=wordhtmlfile
assoc .docm=Word.DocumentMacroEnabled.12
assoc .docx=Word.Document.12
assoc .docxml=wordxmlfile
assoc .dot=Word.Template.8
assoc .dothtml=wordhtmltemplate
assoc .rtf=Word.RTF.8
assoc .wbk=Word.Backup.8
assoc .dotm=Word.TemplateMacroEnabled.12
assoc .dotx=Word.Template.12

Open in new window

0

Featured Post

Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question