0 Replies Latest reply on Sep 16, 2015 8:52 AM by Yu Duan

    How to start up and close a SW regardless of the SW is running or not?

    Yu Duan

      Hi:

       

      I want to design a programme like SW task scheduler, I can start up a SW and close itself regardless of the SW is running or not.

      I check the windows tast manager . If I haved run a SW and then start up a SW task scheduler,, I found two processes of SW. When the task scheduler finished, The SW is runing .

      This is what I want to get.

       

      if I ues exitapp(), I found every SW is closed.

      In How to start a new instance of solidworks, hidden ,there is some ideas ,like:

       

      Dim mySolidworks() As Process

      mySolidworks = Process.GetProcessesByName("SLDWORKS")

      If UBound(mySolidworks) > -1 Then

      bSWXrunning = True

      ' connect to existing SolidWorks

      Else

      ' start new instance of SolidWorks

      End If

       

       

      ' If SolidWorks is running already, do not close

      If bSWXrunning Then

      ' make SolidWorks visible and give control to user

      swApp.UserControl = True

      swApp.Visible = True

      Else

      ' may have to kill SolidWorks

      mySolidworks = Process.GetProcessesByName("SLDWORKS")

      swApp.CloseAllDocuments(True)

      swApp.ExitApp()

      Try

      mySolidworks(0).Kill()

      Catch ex As Exception

      End Try

      End If

       

      are there any ideas?

       

      thinks.