Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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 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 at 17:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.