If you are running this from an intranet (and you said you are) you can use VBscript from IE. I know it's not the best browser, but since in my company it's the official one, i provided some tools to my colleagues to do some actions like this. My best solution (the least worst I found), is to run a batch file, which call Catia
To run the batch file from VBscript (still works on intranet):
shell.Run "C:\foo\startCatia.bat"
And the Batch File should contain CNEXT
, which should open Catia
But then you might have issues with environment variables, and licence. I wasn't able to avoid this, until I found a way to write them in the batch file (of course this has to be done from Catia, so I create in the background of other macros, and it cannot work before the user has launch one of my tool to create this batch). Here is the code to run in Catia to write this batch file:
Sub catmain()
Set oFileSys = CATIA.FileSystem
temp = oFileSys.TemporaryDirectory.Path
envpath = temp + "\env.txt"
GetPath = temp + "\getenv.bat"
runpath = CATIA.SystemService.Environ("USERPROFILE") + "\Desktop\StartCatia.bat"
On Error Resume Next
oFileSys.DeleteFile envpath
oFileSys.DeleteFile GetPath
oFileSys.DeleteFile runpath
On Error GoTo 0
Dim defaults(1111, 2) As String
Set defaultslist = CreateObject("WScript.Shell").Environment
Set GetFile = oFileSys.CreateFile(GetPath, False)
Set getStream = GetFile.OpenAsTextStream("ForWriting")
getStream.Write "set > " & envpath
getStream.Write Chr(10)
getStream.Close
CATIA.SystemService.ExecuteProcessus (GetPath)
Set RunFile = oFileSys.CreateFile(runpath, True)
Set RunStream = RunFile.OpenAsTextStream("ForWriting")
Set envfic = oFileSys.GetFile(envpath)
Set envStream = envfic.OpenAsTextStream("ForReading")
line = envStream.ReadLine
While line <> ""
l1 = InStr(line, "=")
envvar = Left(line, l1 - 1)
dest = Right(line, Len(line) - l1)
defcontent = defaultslist.item(envvar)
If defcontent <> dest Then
'Set each environment variables
RunStream.Write "set " & line & Chr(10)
End If
line = envStream.ReadLine
Wend
envStream.Close
'Add a command to launch Catia
RunStream.Write "CNEXT" & Chr(10)
RunStream.Close
On Error Resume Next
oFileSys.DeleteFile envpath
oFileSys.DeleteFile GetPath
On Error GoTo 0
MsgBox "StartCatia.bat created on your desktop", vbInformation, "hjn fast launcher"
End Sub