rpardee@gmail.com
12/8/2006 7:14:00 PM
This works for me:
require 'win32ole'
wn = WIN32OLE.new('Wscript.Network')
wn.SetDefaultPrinter('\\\mpe-ls1\mpe01lp')
puts("finished")
I'm not sure how the backslash escaping is working there, but like I
say--that's working for me...
HTH,
-Roy
Jan Svitok wrote:
> On 12/8/06, Anders <anders.schneiderman@seiu.org> 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?
>
> If OLE then WMI is the most probable way. Have a look at WMI (Windows
> Management Interface or something like that), if there's something
> interesting. Other possibilities are through the registry or direct
> WINAPI calls (Win32API).
>
> If I understood correctly, you want top reverse the changes made by
> your admins. If that is right, I assume the best place to look for
> information is the admins' script itself. Chances are that it is a
> wsh or .vbs script, that is more or less directly translatable to
> ruby, using Win32OLE. It's possible that it is an .exe file, and that
> is a harder case (regmon from sysinternals might be helpful then).