I need to write a .bat script that will start excel on a specific file.
The hard part is that I don't know the exact path that excel is installed to.
Additionally, I need to start it with an option to make it readonly.
Here is some background to put the problem in context:
Currently the .bat file looks like this:
"C:\My\Path\To\excel.exe" /r "S:\The\Path\To\File.xlsx"
That file is on a shared drive. The user has a shortcut to to that file on their desktop.
When the user clicks on the short cut excel starts on File.xlsx.
But, when another user with a different path to excel does the same thing, the script just flashes the cmd window.
As an aside, I would also like to find a way to eliminate the cmd window from cluttering the screen while this is running.
This is related to this question:
Allow multiple people to work with single readonly excel file
I tried making a short cut on the file and making the target:
start excel /r "S:\The\Path\To\File.xlsx"
Best Answer
I can't test this at the moment, but
I believe you can avoid the batch file. Simply create a shortcut with the following target:Edit: Try the following for a batch file:
Also, I believe you could incorporate the registry key value for the Excel installation path by running the following batch command: