跳至主內容

搜尋

搜尋

Closing Instance Of Bartender

評論

12 條評論

  • Avatar
    Legacy Poster

    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 Then
                                            engine.Stop(SaveOptions.DoNotSaveChanges)
                                        End If
    0
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    Using Bartender 10.1 sr1

     

    Controlling access with VB

     

    Regards

     

    Ryan

    0
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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

登入寫評論。