Kix script – functions.kix

By | March 9, 2011
Function map_drive($drive_letter, $unc)
   COLOR W+/n
   ? "Mapping $drive_letter to $unc"
   USE $drive_letter /del /persistent
   USE $drive_letter "$unc"

   If @ERROR == 0
      COLOR G+/n
      ? "   Connection succesful"
   Else
      print_error(@Error, @SError)
   EndIf
EndFunction

Function print_error($errorno, $errorstr)
   COLOR R+/n
   ? "   Error $errorno - $errorstr"
EndFunction

Function connect_printer($unc)
   COLOR W+/n
   ? "Connecting to $unc"
   If ADDPRINTERCONNECTION ($unc) = 0
      COLOR G+/n
      ? "   Connection to $unc succesful."
   Else
      COLOR R+/n
      ? "   Error connecting to printer $unc"
      print_error(@Error, @SError)
   Endif
EndFunction

Function defatult_printer($unc)
   COLOR W+/n
   ? "Setting Windows default printer to $unc"
   If SetDefaultPrinter ($unc) = 0
      COLOR G+/n
      ? "   Defaulting successful."
   Else
      COLOR R+/n
      ? "   Error defaulting to $unc"
      print_error(@Error, @SError)
   Endif
EndFunction