ThisDoc.Launch No Longer Opens OneNote Shortcuts

ThisDoc.Launch No Longer Opens OneNote Shortcuts

pmartick
Advocate Advocate
281 Views
2 Replies
Message 1 of 3

ThisDoc.Launch No Longer Opens OneNote Shortcuts

pmartick
Advocate
Advocate

Recently updated from Inventor 2023 to 2026.

 

Apparently one of the smaller changes was made to the ThisDoc.Launch method which does not allow it to work with OneNote shortcuts so now I have to find another method.

 

I don't need to do any editing or whatever to the OneNote pages. This is just to open Help Guide pages that document some of my more complex iLogic tools.

 

So far the most promising method I've found so far is to use System.Diagnostics.Process.Start to open a shortcut that I have saved in a folder in my iLogic folder path but when I try to start the process it complains about not being able to find a file in a working directory which is being pointed to the same folder as the Inventor executable:

pmartick_0-1767124910476.png

 

AddReference "System.Diagnostics.Process.dll"
Imports System.IO
Imports System.Diagnostics
Dim siLogicPath As String = iLogicVb.Automation.FileOptions.ExternalRuleDirectories(0)
siLogicPath = Left(siLogicPath, InStrRev(siLogicPath, "\"))
Dim oInfo As New ProcessStartInfo
oInfo.FileName = siLogicPath + "Shortcuts\OneNote Shortcut.lnk"
Process.Start(oInfo)

 

What does the working directory need to be changed to for this to work?

 

Or is this the wrong direction and I need to do something else to open OneNote shortcuts from iLogic?

 

Thanks ahead of time.

0 Likes
Accepted solutions (1)
282 Views
2 Replies
Replies (2)
Message 2 of 3

gopinathmY575P
Advocate
Advocate
AddReference "System.Diagnostics.Process.dll"
Imports System.Diagnostics
Imports System.IO


'Set UseShellExecute = True so Windows resolves the .lnk.

Dim dirs = iLogicVb.Automation.FileOptions.ExternalRuleDirectories
If dirs Is Nothing OrElse dirs.Length = 0 Then
    MessageBox.Show("No External Rule Directories configured. Set one in iLogic options.", "iLogic")
    Return
End If

Dim siLogicPath As String = dirs(0)
siLogicPath = Left(siLogicPath, InStrRev(siLogicPath, "\"))

Dim shortcutPath As String = System.IO.Path.Combine(siLogicPath, "Shortcuts", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OneNote.lnk")

Dim psi As New System.Diagnostics.ProcessStartInfo()
psi.FileName = shortcutPath
psi.WorkingDirectory = System.IO.Path.GetDirectoryName(shortcutPath)
psi.UseShellExecute = True
psi.Verb = "open"

System.Diagnostics.Process.Start(psi)
Message 3 of 3

pmartick
Advocate
Advocate
Accepted solution

I took that sample and replaced your shortcut filepath in the Combine function with the path leading to my shortcut and it still results in the same error.

 

However, comparing the normal OneNote shortcut in the start menu to my page shortcut showed me that OneNote page shortcuts get saved as Internet Shortcuts instead of regular Shortcuts, so the file extension is .url instead of .lnk. So I change the file extension in my sample and add your Working Directory line and it works.

 

AddReference "System.Diagnostics.Process.dll"
Imports System.IO
Imports System.Diagnostics
Dim sLink As String = iLogicVb.Automation.FileOptions.ExternalRuleDirectories(0)
sLink = Left(sLink, InStrRev(sLink, "\")) + "Shortcuts\OneNote Shortcut.url"
Dim oInfo As New ProcessStartInfo
oInfo.FileName = sLink
oInfo.WorkingDirectory = Path.GetDirectoryName(sLink)
oInfo.UseShellExecute = True
Process.Start(oInfo)