Looking for a scripting to connect to a server and purge a printers print queue? - vb.net

Trying to get something like this to work against servers running 2008 and above.
Dim objPrinter As Object
objPrinter = GetObject(“winmgmts://servername/PR53”)
objPrinter.Purge
Running that on server 2003 quickly purges print queue for that printer. Running that against servers running 2008 and above receive cannot create activeX.
Trying to find WMI code to accomplish the same thing. We have software running all over the US and when Zebra printers come back from repair sometimes there may be 1000 print jobs in queue. Looking for something I can include in an existing program that I wrote that configures the networking for the device before use. Would be nice while reconfiguring device the program could call routine that would purge the queue. I will know the printer ID and the server name.
preferarbly the script would be VB.
Trying to register ActiveX on all our current customers server's is not feasible.
Thanks

Related

Detecting a Windows Update Automatic Restart with VB.NET (Before it happens)

My office computer automatically restarts (group policy). I would like to have an app that simply detects that an automatic restart is going to happen, and perform an action (send an email to me). A possible path I found was ARR
(which I found by this question: Detect whether a Windows reboot was due to Windows updates)
However, this is in C, C++, and I'm really just a noob with rudimentary VB.net knowledge. A possible path would be to use GetProcessByName if the automatic update restart is performed by a specific process. Thus my questions are:
Is there a specific process that's started for a Windows Automatic Restart?
Is there a better way to do this?
ARR is probably the most correct way to do this.
To try and stick more to your wheelhouse, you could write a VB app that runs on startup and searches the event logs similar to this

Execute Macro-Script on Remote Computer

I have an requirement to execute macro-script kept on remote machine. DCOM Configuration setting is not set to allow communication between two computers. Even it's not possible to change the DCOM setting in my scenario.
Can I achieve the same requirement using Remote Desktop connection and then invoking macro script (through VBA code)?
I don't know exactly how to invoke script kept on remote machine using VBA?
Any idea/suggestions welcomed!!
This may not exactly answer your question, but may give you an idea.
I faced a the same problem with an application built in Access and the only way I could achieve this is by programming the macro I wanted to run into the application and then let the application periodically check a table on a share drive for "Go" command every few seconds.
On the share drive there was a table like this:
command_id | user | command
======================================
8 | "john.doe" | "update_me"
And all the applications were checking this table. If the app identified itself as user "john.doe", it decided to run the pre-programmed macro "update_me" and delete the row afterwards to prevent it from running again.
You can easily program more advanced stuff, like parameters, periodical execution etc.
It's not perfect, but it works quite nicely. Currently, I have the table on the SQL server and the command request takes cca 0.01s and I use it very often.

coldfusion - cfprint issues with large spool files

I am using cfprint from ColdFusion to print multiple PDFs from a directory. The problem I am having is that when the files are spooled to the printer the size of the file dramatically increases and slows down everything. The file in the folder is 125K and when it is in the printer spool it increases up to 15.7MB. Here is the ColdFusion code:
<cfprint
source="[FILELOCATION]/[FILE].pdf"
color="yes"
printer="[printer name]">
The files will eventually print but it can take upwards of 15-20 minutes. Does anyone have any solutions for this issue? I have tried with both CF generated PDFs and ones that I have created from scratch. Thanks
Queue up two to five at a time. Pause to allow processing. Mark them as printed, move or delete them, move to the next batch...Time this out yourself to see how much time you need to allow. That way you don't compound a bunch of work for the server and create a bottleneck on your CF server.
If you are just doing this with one server consider using a secondary low priority server and run a developer edition fully paid for EULA compliant registered version of Coldfusion (or Railo) and dedicate that server for just printing so your other server can do useful things.
Edit
So the OP has a Coldfusion print bottleneck. In your server that does the printing (same as your CF server I assume?) and IF this is a windows server (not sure your server version), there is print queue folder. Provided you have access to this folder, you can do a few things. You can create a method for FTP-ing your files to this folder (or copy if it is the same server). The printer will queue up the job and off it goes. You can do some functions like check the print queue for file count. If the file count is greater zero, check back in 15 minutes. If the count is zero, copy over a few more files.
You be creating a scheduled task in your CFAdmin and automate. There is a getprinterInfo() so you can check if the printer is off line and do other things like check for another printer somewhere else if you need to reroute print jobs. You can also set up several print servers and attach printers to them and hit several print servers and check print queue folders.
The magic is endless, goal is to offset work to something other than your Coldfusion server.
So to recap:
Seperate concerns by not doing cfprint
Create escape routes to other priters if you can.
If you must use coldfusion then queue up a dedicated Coldfusion server for print management stuff.
Use getPrinterInfo() and dump out things to see what you can use, trap etc.
Ben forta has a tool that can check for several printers, consider incorperating this.
Next use cfftp (or cffile if you are on the same server) provided you have access and copy files to print queue folders, doing no cfprint at all.
Here is a link on print spool stuff (another link in the doc shows you how you can change the spool location).
When it is over you are going to be the coldfusion print master with escape routes and checks and everything.

How to perform VM migration automatically using xenserver?

I'm now trying to write a program which can perform VM migration from one host machine to another within the same data center based on their current CPU temperature automatically. (Basically from hotter machine to cooler one).
I'm now playing around with Xenserver, on which I can perform VM migration easily (Using XenCenter on the controller machine).
I have already come up with the algorithm to select source and destination machine according to their temperature and resource utilization.
However when it comes to writing a real program, I have no idea where to begin with. I would really appreciate your help if anyone can give me some guidance and help.
The program basically consist of two part: One for center control, installed on the management host. And one for guest host(local control). Which should run on dom0 of guest host.
Local control part are suppose to gather CPU temperature and resource utilization information of the local host and all VMs that runs on it. Gathered info will be send to center control part upon request.
Center control part will check the status of all guest host every 5 minutes (By sending request to obtain latest local info). If any of the guest machine gets over-heat, the control machine will choose a destination host and migrate some VMs from the over-heated host to the destination host.
Can I make use of the existing functionality of Xenserver/Xencenter software and how?
What programming language is best for this task ? I know C, C++, Java but can learn the others fast.
Thanks so much for your time!
I have used Python but the Java API is also good.
First have a look at the XenServer Management API that they are exposing for programmers.
Next download the library XenAPI.py to connect with xenserver.
Now to migrate a VM you need the following parameters vm_reference & destination_host_reference .
vm_reference = XenAPI.VM.get_by_uuid(vm_uuid)
destination_host_reference = XenAPI.host.get_by_uuid(destination_host_uuid)
Now migrate the VM :
XenAPI.VM.pool_migrate(vm_reference , destination_host_reference , {"live": "true"})

What are my options to print an email to TIFF from Outlook via an addin?

We have a process at our company that processes TIFF images. I have a project where I want to be able to capture emails that people have received and let them pass it on to our imaging process. Right now forwarding an email isn't really an option but our initial thought was that we could create an Outlook addin that would create and send an image of the email to our internal webservice and it would just work.
I'm developing on Windows 7 with VS2010 and Outlook 2007.
I have the basic addin framework setup - that seems to work OK. The addin is there, popping a regular Windows form where I can do my stuff. But now I'm running into problems. First I was going leverage the built-in Microsoft Office Document Image Writer which can write to TIFFs. However, this doesn't appear to be installed as part of Office 2007 on Windows 7. Then I found some references that it didn't work on Win7 64bit in the first place, and that Microsoft was phasing it out in favor of their XPS printer anyway.
Then I moved on to thinking I could maybe use PDFCreator. This sort of works, except it looks like I have to actually have PDFCreator installed on the client machine, too. I was really hoping I could just bundle the dll and PDFCreator could natively "print", but it seems rely on you setting the active printer to "PDFCreator" and still printing to that. I was already maybe going to run into problems pushing a custom addin out to users in the first place; I don't know if I could get a new printer rolled out as a requirement, too.
On top of that, you apparently can't set the active/default printer in Outlook once it's running. So my plan to run the addin, change the default printer to PDFCreator, print it, then change it back isn't going to work after all anyway.
We really wanted to be able to capture emails as if the user had printed them out and scanned them, which is what they have to do now. I would really not like to rely on copying/pasting into another application if I can help with it.
Sooooooo, what other options might I have? Is there any close to native functionality in Windows or Office that would let me print to something and eventually get a TIFF? Does it look like I'm going to have to try and string together a bunch of 3rd party tools or something? It looks like the only way to "print" an email is to do the MailItem.PrintOut() command, which is just going to go to whatever the current default printer is. Are there any other TIFF-printing things available that wouldn't involve installing a new virtual printer on the end user's machine? Any other ideas? Thanks for any help!
Although you ruled it out at the start of the question...
Assuming you need those tiffs at a central location and not at the employee desktop.... I'd still advise you to have your addin forward the respective mail to a central location (as an attachment to a automated mail, or perhaps just write it to a queue folder on some network location), then have a central process pick it up and print it out to tiff files.
Unless you have exact control over the client machines at your company (which from the sound of it, you don't), you really want to move some fickle as 'switching printers in Outlook' away from the clients.
That doesn't mean this approach doesn't require hacks as well, because that central process will be running outlook to do the work.
I assume it is important that your tiffs look like they were actually printed from Outlook, if not please add that as extra information to your question, as it opens new routes. Like capturing the email-screen rendering and putting that inside a tiff file, which can all be done on any desktop machine.