Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
System Hang
Message
From
24/01/2000 23:32:57
 
 
To
24/01/2000 22:51:28
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Miscellaneous
Thread ID:
00303157
Message ID:
00322022
Views:
36
>>Rather than forcing your will on the rest of the environment for the user, ensure that the printer is installed with the HP LaserJet Series II driver as a distinct device, and then use something to set that as the default printer from within VFP - the Wscript.Network SetDefaultPrinter method is a good way to do so. users may not even realize that you're using the ancient driver this way.
>
>Re: Wscript.Network SetDefaultPrinter
>
>Could you elaborate on this a little?
>

Wscript.Network is one of the automation objects from the Windows Script Host, which can easily be instantiated from within VFP. One of the useful facilities is the SetDefaultPrinter method of the object, from the WSH docs:


Description
Sets the default printer to the remote printer specified.
Syntax
object.SetDefaultPrinter strPrinterName
Parameters
Part Description
object WshNetwork object.
strPrinterName Remote printer name to set as default, such as "\\Server\Printer1."

Example
The following example uses the AddPrinterConnection method to connect a network printer to LPT1: and then sets it as the default printer:
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.AddPrinterConnection "LPT1:", "\\Server\Print1"
WshNetwork.SetDefaultPrinter "\\Server\Print1"



That's the VB version. this translates to:

oWshNet = CREATEOBJECT('Wscript.Network')
oWshNet.SetDefaultPrinter("LPT2:")
* the printer at device LPT2: is now the default device for VFP as returned
* SET('PRINTER',2) and, unless reassigned, SET('PRINTER',3)

I just posted a FAQ entry on where to find details on the WSH; it should be up within the next day. You can specify a UNC or device port, and can attach a Windows Print device by name, port or UNC via some of the other methods.

Time to learn something besides VFP...there's a reason I've been raving about the WSH for months now, and why JVP is so insistant that we need to learn VB and VBScript and the scripting host, and come February 17, the capabilities of the WMI hit the fan, too...
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform