on 09-18-2008 7:26 AM
Hai To All,
While starting my addon iam checking some condition if it returns false i need to terminate the SAP application.
How to do that????
Regards,
Anitha
Do u need to terminate ur Addon or whole SAP application..??
TO stop ur add-on application use
System.Windows.Forms.Application.Exit()
To exit whole SAP application, i guess u can Declare a process and Exit it or stop it, just look in google for some samples to stop the application in by exiting a process.
Hope it helps,
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its Ok David,
But i didt connect my addon or company.....Before that itself i need to close the application..
Here is my snippet Code,
If CheckIfServiceIsRunning("Found") = True Then
SetApplication()
.....
....
Else
System.Windows.Forms.MessageBox.Show("Run The Setup File!!!!")
System.Windows.Forms.Application.ExitThread()
System.Windows.Forms.Application.Exit()
endif
Here how to give the menuitem????
Regards,
Anitha
Then if thats the case u need to exit the EXE.
Just check the below function which i found on google, i guess u could modify it to exit the SAP Application. In the sample he is starting the exe.
Public Function StartAndWait(ByVal ProcessPath As String, ByVal Licence As Integer)
Dim startProcess As System.Diagnostics.Process
Try
startProcess = New System.Diagnostics.Process()
startProcess.StartInfo.FileName = ProcessPath
startProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
startProcess.Start()
'Wait until the process passes back an exit code
startProcess.WaitForExit()
' Check Exit code to see if process finished without error.
If startProcess.ExitCode <> 0 Then
MessageBox.Show("Exit Code: " & startProcess.ExitCode)
End If
'Free resources associated with this process
startProcess.Close()
StartAndWait = True
Catch
StartAndWait = False
MessageBox.Show("Could not start process " & ProcessPath, "Error")
End Try
End Function Public Function StartAndWait(ByVal ProcessPath As String, ByVal Licence As Integer)
Dim startProcess As System.Diagnostics.Process
Try
startProcess = New System.Diagnostics.Process()
startProcess.StartInfo.FileName = ProcessPath
startProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
startProcess.Start()
'Wait until the process passes back an <strong class="highlight">exit</strong> code
startProcess.WaitForExit()
' Check <strong class="highlight">Exit</strong> code to see if process finished without error.
If startProcess.ExitCode <> 0 Then
MessageBox.Show("Exit Code: " & startProcess.ExitCode)
End If
'Free resources associated with this process
startProcess.Close()
StartAndWait = True
Catch
StartAndWait = False
MessageBox.Show("Could not start process " & ProcessPath, "Error")
End Try
End Function
Hope it helps u,
Vasu Natari.
ok, I tried it and functional solution for you is:
1. Add reference to your project for System.Diagnostics (Project - Properties - References and check System.Diagnostic)
2. Use this code for closing SAP
Dim Proc() As Process = Process.GetProcesses()
For Each p As Process In Proc
If InStr(p.ProcessName, "SAP Business One") Then
p.CloseMainWindow()
End If
This works, I tested it now. Hope it helps.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.