...so this is the solution to the question you have originally stated:
"opening a file with Inventor ReadOnly from the command line"
Now you have changed your request a little bit, so if you mark my answer as solution I will be glad to support you in your new task of
"opening a file with Inventor ReadOnly from a VB.net executable"
(you know: my Autodesk mentor told me that I need "solutions"...).
Assumptions
I will assume the followings:
- Inventor is on the 2020 release, and installed in the default folder (as stated above in the other posts)
- Inventor ReadOnly is already initialized on your system and in the active userprofile
- your ipj file is correct and properly loaded
I hope I didn't forget anything 🤔
The logic
As you already realized if you call the invRO.exe passing a FQFN of an inventor file, that file will be opened in Inventor ReadOnly. The problem is that, if you do it again, another instance of Inventor ReadOnly will be opened, and you do not want this. The batch code I am giving you will first check if inventor ReadOnly is running, and then decide how to handle the argument you have passed: inventor ReadOnly will be launched if needed, or simply the file will be opened.
How TO
You can easily achieve what you have asked if you place a properly crafted cmd file in your "C:\Windows\System32" folder, or in any other folder included in the path. If you do not want to place the file in a path folder, then the only difference will be that you will need to call the cmd file with full qualified file name.
Usage
In my computer I have created the C:\Windows\System32\InvRO.cmd
Then I simply need to enter in the commandline the following
C:\> invro D:\CAD\myPart.ipt
and the inventor file myPart.ipt will be opened in Inventor ReadOnly without changing file associations.
Be aware to wrap the filename in quotes in case you have spaces inside, otherwise the interpreter could misinterpret the argument, assuming that 2 arguments are passed:
C:\> invro "D:\CAD\my Part.ipt"
will work, while
C:\> invro D:\CAD\my Part.ipt
will almost for sure fail
The InvRO.cmd file
Leaving away bells and whistles, I have simply written the bare code you need to achieve what you have asked. You can freely adapt to your specific needs.
tasklist | find /I "InvRO.exe" >nul 2>&1 && (
"%~1"
) || (
start "%ProgramFiles%\Autodesk\Inventor 2020\bin\InvRO.exe" "%~1"
)
:EOF
Additional Considerations
With some additional effort it would be possible to control the active ipj from the batch file, but since you have already indicated that you need to realize a little bit different task, I think this can be considered a valid solution for your current question, and we'll see in the future how to handle the other task.
I hope this is a solution to your question.
Massimo Frison
CAD R&D // PDM Admin · Hekuma GmbH