Commander And Vbscript Follow

0
Avatar
Legacy Poster

Here is what I am attempting to do:

 

Commander detects a trigger file and launches the print documents which are connected to an SQL database.  This database holds records of all generated labels.  Using SQL commands I have the labels sorted properly and all possible data to be printed on one record.  The main "to print" field is a "print date" being NULL.

 

The next step is for Commander to launch a vbcsript to go in and update all records with a NULL print date to have today's date.

 

The last step is for Commander to launch a second vbscript to go in and delete all records where the print date is older than 14 days.

 

This emulates what we currently have in our old print system.

 

The issue is, that when I run these manually from a command prompt, they all seem to work correctly, however when commander launches the scripts, the user being used to log into the database through the script is PONTUS$ (the name of the server).  I have set every databse connection user/pass I can find in the services and in Commander options but can't figure this out.

 

Am I doing this correctly?  Is this even possible through commander?

 

9 comments

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

It sounds like you're attempting something that Commander isn't ordinarily best suited to, although that is not to say it's not possible.  Assuming Commander is running as a Windows service you should set the Commander service logon to be the domain user account which you wish the script to run under.

 

Wouldn't it be best if you have all of these actions contained in a single VB script because in that way you can better programmatically control the sequence of database commands you execute.

0
Avatar
Legacy Poster
Comment actions Permalink

The problem is we do have the Bartender service set to login under a specific account (Services.msc - Bartender System Service - Logon Tab - "This Account" with the standard login/pass needed).  However, the vbscript is launched as user SERVERNAME$ and is unable to connect.

 

We were hoping to use Commander to detect and process the print routines as opposed to loading an automated schedule client on the Bartender server and having it control everything.

 

Yes, if we can actually get this to work, I can combine everything under a single script so that is not an issue.

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

Hmm, I guess the VB script is running under a thread that doesn't inherit from the Commander service and BarTender process.  Perhaps if you create an SQL Server login, not Windows, on your SQL Server and make the connection in your script using that login instead it might work...?

0
Avatar
Legacy Poster
Comment actions Permalink

I attempted to place the username and password inside the vbscript itself and commander still shows the same error being returned from SQL Server about the invalid username SERVERNAME$.  It's like the Commander called script is being passed a forced username login of the server name itself.

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

Did you try using an SQL Server login as opposed to a Windows login?  You might want to contact technical support directly to see if there is something that can be done here.  As an aside, in future versions of BarTender I believe we'll be making the ability to do this sort of thing much easier.

0
Avatar
Legacy Poster
Comment actions Permalink

As an alternative, I could have a trigger file for our separate automated system to wait for and let it process the vbscripts.

 

However, I seem to be unable to figure out how to have the Commander create a file correctly.

 

If I set up two commands under a task, the first Bartender command to print the label document from the SQL database and the second Operating System command to create a file, they both seem to run at the exact same time.  I would expect the commands to go 1 then 2 then 3 instead of 123 all at once.

 

Is there a way to have Commander process the steps one-at-a-time and not move to step two until step one completes?  Or is there a way to have a file generated at the end of the btw document process?

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

At present, the way to maintain a sequence in this way is to have the output from a command in task A be the trigger that executes task B.

0
Avatar
Legacy Poster
Comment actions Permalink

And how would that be done?  The last step in task A to create a file happens the minute task A runs.  Task B would still kick off at almost the same time as if it were in task A.

 

Or that is how it seems to me right now.

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

Hmmm, in your OS command you could fire up CMD and run a batch file that contains the below command, to introduce a 5 second delay, before doing something else like calling your VB script.

 

ping -n 5 127.0.0.1 > NUL 2>&1

Please sign in to leave a comment.