• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 508
  • Last Modified:

installing a printer via vbscript, with no user interaction

im trying to install a printer via vbscript with no user interaction

my code is returning, invalid arguments

I have also attached the INF file being used, (in txt format)

Option Explicit
On Error Resume Next
 
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
 
 
Const SOURCE = "\\%DSSERVER%\eXpress\Packages\Citrix\Source\910a-PSourceGlobal\"
 
Const COMMAND1 = "Rundll32 PrintUI.dll,PrintUIEntry /ia /f"
 
'Install "Canon CLC-iR C3220-C1 PCL5c" Driver 
 
WshShell.Run COMMAND1 & Space(1) & Chr(34) & SOURCE & "Canon CLC3220 PCL5c\P52KUKAL.INF" _
	& Chr(34) & " /m " & Chr(34) & "Canon CLC-iR C3220-C1 PCL5c" & Chr(34) & " /u", 0, True 
 
Set WshShell = Nothing

Open in new window

P52KUKAL.txt
0
lpkramit
Asked:
lpkramit
1 Solution
 
TakedaTCommented:
I did notice there is an environment variable in the path on line 8.  This would need to be retrieved differently.  I modified your script, give it a try.  If you get any errors, please post what they are and what lines they are on.


Option Explicit
On Error Resume Next
 
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
 
strDSServer = WshShell.ExpandEnvironmentStrings("%DSSERVER%")
Const SOURCE = "\\"&strDSServer&"\eXpress\Packages\Citrix\Source\910a-PSourceGlobal\"
 
Const COMMAND1 = "Rundll32 PrintUI.dll,PrintUIEntry /ia /f"
 
'Install "Canon CLC-iR C3220-C1 PCL5c" Driver 
 
WshShell.Run COMMAND1 & Space(1) & Chr(34) & SOURCE & "Canon CLC3220 PCL5c\P52KUKAL.INF" _
	& Chr(34) & " /m " & Chr(34) & "Canon CLC-iR C3220-C1 PCL5c" & Chr(34) & " /u", 0, True 
 
Set WshShell = Nothing

Open in new window

0
 
Mark PavlakCommented:
If you have a way to run this remotley or place in the startup folder on the users pc.
Set WshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\ServerName\PrinterShareName"
PrinterDriver = "UNIDRV.DLL"
WshNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver
WshNetwork.SetDefaultPrinter "\\ServerName\PrinterShareName" 

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now