Closing Instance Of Bartender
Hello again,
I've got BarTender automating along nicely.......but have just discovered a problem when it comes to closing the instance of bartender.
My previous post http://forums.seagullscientific.com/index.php?/topic/2222-automating-label-printing-from-access-db-random-printers/
Shows how i get to the stage of printing out the labels i require, it's just that in the task manager, the number of bartender.exe instances keep adding up and up and up each time i use my access database to print a label.
I'm using bt.quit after each label is printed, but the bartender.exe instance is still in the task manager, and on our XP machines, this is causing them to slow down and grind to a halt.
Is there something i'm missing?
Regards
Ryan
-
Legacy Poster
★ BarTender Hero ★
when youve finished printing your labels make sure you are stopping the BT engine, so assuming your engine object is labelled as "engine" the following may help you out
If engine.IsAlive Thenengine.Stop(SaveOptions.DoNotSaveChanges)End If0 -
Legacy Poster
★ BarTender Hero ★
Hello,
thanks for your reply, but i'm not sure i understand the engine part. The process that runs and won't stop is bartender.exe
My code to initialize is
Dim btApp As BarTender.Application
Set btApp = CreateObject("BarTender.Application")
Is this what you need to help out?
Regards
Ryan
0 -
Legacy Poster
★ BarTender Hero ★
Please also note that Print Station also uses a bartender.exe process so killing all instances wouldn't be a feasible solution as we need Print Station open and running too
Regards
Ryan
0 -
Legacy Poster
★ BarTender Hero ★
sorry i should of asked but what version of bartender are you running? as that code I supplied was for use with bartender 10 SR4 SDK integration
Cheers,
Scott
0 -
Legacy Poster
★ BarTender Hero ★
Using Bartender 10.1 sr1
Controlling access with VB
Regards
Ryan
0 -
Legacy Poster
★ BarTender Hero ★
ah right, apologies ive used vb.net in 3.5 framework for my solutions. the only thing i could think is to look for a quit or close command against the object you are creating maybe? and see where that ends up. other than that I cannot really offer any more assistance sorry.
one thing are you using the SDK because i could provide you with the function we use in .NET to manage to instance closure after printing of labels?
Cheers,
Scott
0 -
Legacy Poster
★ BarTender Hero ★
No i'm not i'm afraid, I dont completely understand it and we have a number of different Windows OS kicking about so it's a biut of a mission getting everything to work on each machine.
If you have an easier guide then the white paper i'd be interested in that?
Regards
Ryan
0 -
Legacy Poster
★ BarTender Hero ★
Like I said this is .NET based integration of the BT10 SR4 SDK but I hope it is of some use to you in finding a workable result.
it might be worth taking another look at the SDK with the code below as it does handle the disposal of the BT instance when youve finished printing.
'Bartender10.0 'get a new bartender engine instantiated engine = New Engine(True) 'check format has been cleared and clear if still in use. If format IsNot Nothing Then format.Close(SaveOptions.DoNotSaveChanges) End If 'load the label into memory. format = engine.Documents.Open(Label.LabelDirectory & Label.LabelFormat) ' Get the printer and assign it to the format. format.PrintSetup.PrinterName = PrinterName Dim waitForCompletionTimeout As Integer = 10000 ' 10 seconds Dim oleDB As New Seagull.BarTender.Print.Database.OLEDB(Label.Database) oleDB.UserID = Label.DBUsername oleDB.SetPassword(Label.DBPassword) If format.DatabaseConnections.Count > 0 Then format.DatabaseConnections.SetDatabaseConnection(oleDB) End If ' Retrieve the QueryPrompts object. Dim queryprompts As Database.QueryPrompts = format.DatabaseConnections.QueryPrompts ' set the name queryprompt to the order number value. queryprompts("ID").Value = BoxToPrint.ToString Dim messages As Messages = Nothing format.Print(strApp, waitForCompletionTimeout, messages) Dim messageString As String = Constants.vbLf + Constants.vbLf & "Messages:" For Each message As Seagull.BarTender.Print.Message In messages messageString &= Constants.vbLf + Constants.vbLf + message.Text Next message If engine.IsAlive Then engine.Stop(SaveOptions.DoNotSaveChanges) End If
Cheers,
Scott
0 -
Legacy Poster
★ BarTender Hero ★
Hello again,
I'm still struggling to find a solution to my original post i'm afraid
has anyone got any more input?
Regards
Ryan
0 -
Legacy Poster
★ BarTender Hero ★
Hello again,
I'm still struggling to find a solution to my original post i'm afraid
has anyone got any more input?
Regards
Ryan
Hey Ryan,
New to this forum, however I've conjured up this little beauty in VBScript:
strComputer = "." strProcessToKill = "bartend.exe" SET objWMIService = GETOBJECT("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") SET colProcess = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'") count = 0 FOR EACH objProcess in colProcess objProcess.Terminate() count = count + 1 NEXT
0 -
Legacy Poster
★ BarTender Hero ★
Hello,
Sorry for the delay, i've been off work for a couple of days
Thanks for your reply, where would this script go? Also, would this kill all instances of BarTender as we also use PrintStation on the same machines so i'm concerned this would have an effect on that too?
Regards
Ryan
0 -
Legacy Poster
★ BarTender Hero ★
Hello.
I'm aware this post is old, but for future reference...
After you do:
btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges) btApp.Quit()
Add line:
System.Runtime.InteropServices.Marshal.ReleaseComObject(btApp)
And that will chase down any leftover bartend.exe processes.
Regards,
0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
12 commentaires