Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get rid of OSPPSVC (Office Software Protection Platform Service).

Then, I have replaced the links to open Office programs with a link to launcher.bat:

@echo off
title Launching Office...
Set target=%1

sc config osppsvc start= demand
net start osppsvc

:check
if exist "%target%.exe" goto launch
Set/p target="Introduce the program to open:"
goto check

:launch
start %target%.exe %2

sleep 10

sc config osppsvc start= disabled
net stop osppsvc

And I can open files if, in the console, I enter:

"C:\Path\To\Office14\launcher.bat" winword "C:\Path\To\File\doc.docx"

But, since I want explorer integration, I have tried associating .docx extension to be opened with

"C:\Path\To\Office14\launcher.bat" winword "%1"

But it doesn't work: the batch file runs but doesn't open Word (it asks "Introduce the program to open:").


Edit: Fixed code:

@echo off
title Launching Office...
Set name=%1

sc config osppsvc start= demand
net start osppsvc

:check
Set target="%~dp0%name%.exe"
if exist %target% goto launch
Set/p name="Introduce the program to open:"
goto check

:launch
start "" %target% %2

sleep 10

sc config osppsvc start= disabled
net stop osppsvc
share|improve this question
up vote 0 down vote accepted

Actually it appears that you need to specify which folder %target% is in, unless somehow the Office path is in your %PATH%.

share|improve this answer
    
But if launcher.bat is in the Office folder, shouldn't it work? – Oriol Feb 3 '14 at 17:49
1  
Not necessarily. You may want to test to see what the script sees as its working directory when its called. It's probably working from the directory where %1 is. – Wally Feb 3 '14 at 17:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .