Redirect

(Engine-Level Function)

Description: Redirects a local device to network resource.
Returns: Nothing
Usage: Script Only.
Function Groups: Printer,  Software and Hardware,  Network
Related to: DefaultPrinter
Format: Redirect(Local, Remote)
Parameters:  
Local
Required. Any text expression giving the local device to redirect, for example "G:", "LPT1:", "DEF:" (default printer), etc.
Remote
Required. Any text expression giving the network resource to map the local device to. If this parameter is an empty string or invalid, the current connection for the device Local is disconnected.
If Local has any value other than "DEF:", this parameter must be the same form used by the Windows™ command prompt, "net use" function:
"\\MyServer\MyPrinter"
If Local has a value of "DEF:", the value of this parameter has three elements separated by commas, as follows:
<printer name>, <driver name>, <port>
Each of these elements must be valid to have a valid Remote parameter. If any are invalid, programs such as Print Manager may revert back to the previous valid printer, while other programs may have unpredictable behavior.
Comments: Caution should be exercised when using this statement, since the redirection of the device is permanent - execution of the statement causes the change to be written to the Windows™ registry. For this reason, when using "DEF:" (the Windows™ default printer), it is always a good idea to use the DefaultPrinter function prior to doing the Redirect, so that the original default printer may be restored at a later date.

Example:

If ZButton(10, 40, 110, 10, "Print", 1);
[
  oldP = DefaultPrinter() { Keep track of original printer };
  Redirect("DEF:" { The Windows default printer },
           "\\Serve1\NPrinter, HPPCL5MS, Ne00:"
           { The printer on the server });
  PrtScrn() { Do a printout of the screen };
]

A press of the button causes the default Windows™ printer to be redirected to the printer called NPrinter on the server called Serve1. The rest of the string indicates the driver to be used in this redirection.