Skip to main content
5-Regular Member
September 26, 2024
Solved

Run Creo Parametric as scheduled task

  • September 26, 2024
  • 6 replies
  • 3784 views
Hi all,
 
I would like to create a program that automatically starts Creo Parametric and do a set of operations. To start I created a basic program that only starts Creo and connects to Windchill. Here I already run into some problem where the program runs fine when started normally. However when i start it from Windows Task Scheduler it only runs when the user is logged on. If I select "Run wether the user is logged on or not", Creo fails to start and returns a general error. The user account and machine are the same in all situations. Anyone have an idea how to run Creo as scheduled task? I am using Creo Parametric version 10.0.4.0 and Windows Server 2019.
 
---------- VB.net code ----------
Imports System.IO
Imports pfcls

 

Module Module1
    Const creoOptions As String = "-g:no_graphics -i:rpc_input"
    Const creoStartup As String = "C:\PTC\Creo_10\Creo 10.0.4.0\Parametric\bin\parametric.exe"
    Const logFilePath As String = "D:\_TaskScheduler\DXFWorker\CreoAsyncConnect.log"
    Const proCommMsg As String = "C:\PTC\Creo_10\CREO10~1.0\COMMON~1\X86E_W~1\obj\pro_comm_msg.exe"
    Const ptcWfCache As String = "D:\_TaskScheduler\DXFWorker\work\.cache"
    Const ptcWfRoot As String = "D:\_TaskScheduler\DXFWorker\work\.wf"
    Const ptcWldRoot As String = "D:\_TaskScheduler\DXFWorker\work\.wld"
    Const windchillLogin As String = "********"
    Const windchillPassword As String = "********"
    Const windchillServer As String = "********"

 

    Sub Main()
        Using sw As New StreamWriter(logFilePath)
            Environment.SetEnvironmentVariable("PRO_COMM_MSG_EXE", proCommMsg, EnvironmentVariableTarget.Process)
            Environment.SetEnvironmentVariable("PTC_WF_CACHE", ptcWfCache, EnvironmentVariableTarget.Process)
            Environment.SetEnvironmentVariable("PTC_WF_ROOT", ptcWfRoot, EnvironmentVariableTarget.Process)
            Environment.SetEnvironmentVariable("PTC_WLD_ROOT", ptcWldRoot, EnvironmentVariableTarget.Process)

 

            Dim asyncConnection As IpfcAsyncConnection = Nothing
            Try
                sw.WriteLine("Start Creo")
                Dim cAC As New CCpfcAsyncConnection
                asyncConnection = cAC.Start(Chr(34) & creoStartup & Chr(34) & " " & creoOptions, Nothing)
                Dim session As IpfcBaseSession = CType(asyncConnection.Session, IpfcBaseSession)
                sw.WriteLine("Creo started")

 

                sw.WriteLine("Connect Creo to Windchill")
                session.AuthenticateBrowser(windchillLogin, windchillPassword)
                Dim serverLocation As IpfcServerLocation = session.GetServerLocation(windchillServer)
                sw.WriteLine("Creo connected to Windchill")
            Catch ex As Exception
                sw.WriteLine(ex.Message & vbCrLf & ex.StackTrace)
            Finally
                sw.WriteLine("Close Creo")
                If Not IsNothing(asyncConnection) Then
                    asyncConnection.End()
                End If
                sw.WriteLine("Creo closed")
            End Try
        End Using
    End Sub

 

End Module
 
---------- Script output ----------
Start Creo
pfcExceptions::XToolkitGeneralError
at pfcls.ICpfcAsyncConnection.Start(String _CmdLine, Object _TextPath)
at CreoAsyncConnect.Module1.Main()
Close Creo
Creo closed
Best answer by Sibu

create batch file to open the creo. and call this batch file in the Task sheduler with repeat interval timings , and set it dont start a new instance.

6 replies

23-Emerald III
September 26, 2024

Windows does things differently when apps are run through the task manager.

You do not have any mapped drives, etc.

Take that into account in your application.

 

Can you explain for what purpose you need to run Windchill/Creo as a task?

5-Regular Member
September 26, 2024

I want Creo to process a batch of files and report symbols that occur on drawings. Since there are many files (1000's), I thought it would be best to start Creo, process say 20 drawings, and then restart and cleanup the cache. This way there should not be any problems caused by disk space or full memory.

Dale_Rosema
23-Emerald III
23-Emerald III
September 26, 2024

Not sure, but couldn't you just clear the memory after certain number of files instead of restarting Creo?

 

Automate:

File

Manage session

Erase Not Displayed

 

RPN
18-Opal
September 26, 2024

You can’t start Creo in that way, either with parametric.exe plus psf or just start the batch, The Creo exe is since years the xtop.exe, no idea why this was never changed. And yes g:no_graphics -i:rpc_input this args are required as well. This args must be given to the xtop. If you just start the parametric.exe you need to know which keys you want to use. Try it by yourself.

24-Ruby III
September 27, 2024

Hi,

login to PTC Support and use following link

https://www.ptc.com/en/support/search/#q=g%3Ano_graphics

 

In  CS300745  I found following information ...

Creo Parametric when launched with -g:no_graphics is made to run a trail file

This means you can:

1.] generate trail file

2.] run batch file containing parametric.exe -g:no_graphics PATH_to_trail_file

 

RPN
18-Opal
September 30, 2024

@MartinHanak @your answer is off topic, he tries to create an asynchronous session, and this does not work because the specified Creo command is invalid, as far I can see.

Sibu7-BedrockAnswer
7-Bedrock
October 18, 2024

create batch file to open the creo. and call this batch file in the Task sheduler with repeat interval timings , and set it dont start a new instance.

17-Peridot
March 13, 2025

Hmm - you might consider a scheduled task and CREOSON to do some heavy lifting.

http://www.creoson.com/functions.html

 

>batch file to launch CREOSON and then the script (psudo code) follows<

 

Execute the basic psudo code (not tested - you can do this in JavaScript (Node.js) or with Python (CREOPYSON)

connection : start_creo

connection : connect

connection : is_creo_running

windchill : set_server

windchill : authorize

windchill : set_workspace

windchill : list_workspace_files

for each drawing

      file : open <drawing>

           drawing : list_symbols

           for each symbol ...

                <saveSymbolName_whereever>

      file : erase

... when done

connection : disconnect

connection : kill_creo

 

This will not be the fastest ... but should logically get the results and avoid memory problems because you are clearing creo memory each drawing processed.

 

Dave

 

14-Alexandrite
October 21, 2024

I'm not sure what the Windows Task Scheduler adds/removes to/from the environment of a task (others named mapped network drives).
(Maybe a graphical desktop session is "promised" to exist for the task somehow, but not present in your use case?)

Maybe the PTC TOOLKIT related COM service does not work in this context? From VB/VBA/.NET, the connection to Creo is established via the Windows COM technique.
If you can, try the C/C++ (both paid) or Java OTK (free/paid) API avoiding COM. (Sorry, this is a workaround, not a solution.)


We successfully automated Creo for processing 10k..100k objects with an asynchronous Pro/TOOLKIT (C/C++) application, with and without Windchill.
Creo stability issues occurred (despite erasing everything from session), too, but are prevented by restarting Creo every 500..1000 processed objects. During this restart, all PTC/Creo related interprocess communication processes are killed and caches are cleared (to have a clean next Creo start).

This works in a context of an interactive desktop session and also in a no-graphics Windows Service context using this tool chain:

Create/configure a Windows Service with something like, for example, nssm.exe ( https://nssm.cc/download )

nssm -> Java application -> batch script (incl. kill-script/cache reset etc.) -> ansynchronous TOOLKIT application -> Creo

(It works without the Java application, too.)
This service runs as a user, created only for this purpose.

Where exactly and with what error code/exception fails the connection attempt?

October 23, 2024

try autologon registry hack - this will take care of task scheduler 'run whether user...' property

try to run creo without 'no_graphics' switch, if possible, otherwise creo will run in WIN32_GDI graphics mode and that may cause you some grief...

try not to run your vbs app directly from the task scheduler - create a wrapper batch or powershell script and set task's property to allow interaction - this will help with debugging

you could try to use tasklist and taskkill commands or powershell ...-Process cmdlets to clear up memory when a creo footprint exceeds some given limit