From: vasudevram Date: 2006-12-08T23:50:07+09:00 Subject: Re: Using Ruby to change printer preferences in Win32 Anders wrote: > Our Windows XP sys admins recently changed things so that every day, > our networked printer preferences are reset using a script. Rather > than changing the preferences by hand every day so they suit my work > needs, I'd like to write a Ruby program I can run each morning. Any > pointers on where to get started? For example, is this something I > should > do via Win32OLE? If so, where do I find the right OLE calls to change > printer printing prefs? > > Thanks, > Anders Schneiderman >> do via Win32OLE? If so, where do I find the right OLE calls to change > printer printing prefs? In the MSDN documentation, probably. Its one of the main sources of docs for Windows development. A few ideas: - once you've found the docs (don't know if there are OLE calls, you might have to use Win32 or .NET APIs), you can either: a) write a C/C++ program that does the printer pref setting, then call it from Ruby via system() and pass the needed arguments (if not too many, and if it work well to pass them as command-line args) or else via a file that the Ruby program writes to and the C/C++ program reads from. Though system() is a little slow, as it means spawning an external EXE, if its done only once a day it might not matter. b) write a Ruby-C/C++ extension to wrap the needed Windows calls so you can call the needed APIs directly from Ruby. This is probably more work than a). c) use some other option, like communicate between Ruby and C/C++ programs via sockets. Again, some more work. ~~~~~~~~~~~~~~~~~~~~~~ Vasudev Ram Dancing Bison Enterprises http://www.dancingbison.com ~~~~~~~~~~~~~~~~~~~~~~