Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use the startup service that comes on the API disk.<br> Here is the class I use to register/unregister.<br> The CReg class I got from here : <a href="http://www.getcodesamples.com/src/511D570B/359F7F33" rel="nofollow">RegistryKeyAccess.vb</a></p> <p>Imports Microsoft.Win32</p> <pre class="lang-vb prettyprint-override"><code>Public Class ThincStartupReg Public Overloads Shared Sub Register(ApplicationPath As String, ApplicationName As String, AppType As enumAppType, wait As Boolean, LaunchType As enumLaunch) Try Dim ObjReg As New CReg Dim regCreated As Boolean If ObjReg.ReadValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\StartupService\", "State") Then 'Startup Service is installed If Not ObjReg.ReadValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; ApplicationName, "Enabled") Then 'No entry for this program regCreated = ObjReg.CreateSubKey(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; ApplicationName) Else regCreated = True End If If regCreated Then ObjReg.WriteValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; ApplicationName, "Type", "Process") ObjReg.WriteValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; ApplicationName, "Name", ApplicationName) ObjReg.WriteValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; ApplicationName, "Enabled", "True") ObjReg.WriteValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; ApplicationName, "Wait", If(wait, "True", "False")) ObjReg.WriteValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; ApplicationName, "Type", If(AppType = enumAppType.Process, "Process", "Service")) ObjReg.WriteValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; ApplicationName, "Launch", If(LaunchType = enumLaunch.LaunchOnce, "Once", "Monitor")) ObjReg.WriteValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; ApplicationName, "File", ApplicationPath) End If End If Catch ex As Exception Throw ex End Try End Sub Public Overloads Shared Sub Register(ThisAssembly As System.Reflection.Assembly, ByVal AppType As enumAppType, ByVal Wait As Boolean, ByVal LaunchType As enumLaunch) Dim AppName = ThisAssembly.FullName.Split(",")(0) Dim AppPath = ThisAssembly.Location Register(AppPath, AppName, AppType, Wait, LaunchType) End Sub Public Shared Sub UnRegister() Try Dim ObjReg As New CReg Dim AppName = System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(",")(0) If ObjReg.ReadValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\StartupService\", "State") Then If ObjReg.ReadValue(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; AppName, "Enabled") Then ObjReg.DeleteSubKey(ObjReg.HKeyLocalMachine, "SOFTWARE\OAC\Startup\" &amp; AppName) End If End If Catch ex As Exception Throw ex End Try End Sub End Class </code></pre> <p>If you're not sure the install service will be installed you could just add your shortcut to the startup folder and then just loop until the OSP process has started.</p> <pre class="lang-vb prettyprint-override"><code>Public Shared Function Wait(Timeout As TimeSpan) As Integer If File.Exists("C:\OSP-P\OSPMNGCD.CNC") Then Dim startTime = Now Dim myProcess As Process() = Process.GetProcessesByName("PNC-P200") While myProcess.Length = 0 If Now.Subtract(startTime) &gt;= Timeout Then Return -1 myProcess = Process.GetProcessesByName("PNC-P200") Thread.Sleep(1000) End While 'OSP Started Return 1 End If 'Simulation mode (not on a machine) Return 2 End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload