Update Printer IP using cscript or kace.
We have printers that we are attempting to change the IP address of. The printer models are the same. However, the IP will change. I am looking for a way in kace to do this automated or cscript. Thoughts?
Thanks in advance...
MLands
Answers (5)
I moved away from ps1 as I was unable to get around invoking execution bypass.
I am now using cscript. It will remove the printers, but now it will not re-add. However, if I kick off the script from Kace, the printers do not add.
' Add printer driver
Set objShell = CreateObject("WScript.Shell")
objShell.Run "cscript ""$(KACE_DEPENDENCY_DIR)\prndrvr.vbs"" -a -m ""Canon iR-ADV C5550/5560 UFR II"" -i ""\\ulmfile\it\Installs\Drivers\printers\CanonIRAc5550i\UFRII_V30.30_Set-up_x64\Driver\CNLB0UA64.INF""", 0, True
' Add printer ports
objShell.Run "cscript ""$(KACE_DEPENDENCY_DIR)\Prnport.vbs"" -a -r 10.200.51.121 -h 10.200.51.121 -o raw -n 9100", 0, True
objShell.Run "cscript ""$(KACE_DEPENDENCY_DIR)\Prnport.vbs"" -a -r 10.200.51.122 -h 10.200.51.122 -o raw -n 9100", 0, True
' Add printers
objShell.Run "cscript ""$(KACE_DEPENDENCY_DIR)\Prnmngr.vbs"" -a -p ""Printer 1"" -m ""Canon iR-ADV C5550/5560 UFR II"" -r ""10.200.51.121""", 0, True
objShell.Run "cscript ""$(KACE_DEPENDENCY_DIR)\Prnmngr.vbs"" -a -p ""Printer 2"" -m ""Canon iR-ADV C5550/5560 UFR II"" -r ""10.200.51.122""", 0, True
' Add another printer driver
objShell.Run "cscript ""$(KACE_DEPENDENCY_DIR)\prndrvr.vbs"" -a -m ""RICOH MP C6003 PCL 5c"" -i ""\\ulmfile\it\Installs\Drivers\printers\HoustonPrinter\Ricoh Copier - z73961en\disk1\OEMSETUP.INF""", 0, True
' Add another printer port
objShell.Run "cscript ""$(KACE_DEPENDENCY_DIR)\Prnport.vbs"" -a -r 10.201.51.151 -h 10.201.51.151 -o raw -n 9100", 0, True
' Add another printer
objShell.Run "cscript ""$(KACE_DEPENDENCY_DIR)\Prnmngr.vbs"" -a -p ""Printer4"" -m ""RICOH MP C6003 PCL 5c"" -r ""10.201.51.151""", 0, True
' Open printer control panel
objShell.Run "Control Printers", 0, True
' Exit script
WScript.Quit
Directory $(KACE_SYS_DIR)File $(KACE_SYS_DIR)Parameters //nologo $(KACE_DEPENDENCY_DIR)\Add_Network_Segmented_Printers.vbs
Comments:
-
Assuming you're not using a print server and these are pretty much unmanaged? - AmberSDNB 6 months ago
Correct, we only have 5 total printers but a hand full of users that go between locations
Comments:
-
You said " It will remove the printers, but now it will not re-add. However, if I kick off the script from Kace, the printers do not add."
Little confused by this, does it work when you run it manually? Just not through Kace? By your description, it doesn't sound like manual run works either. - AmberSDNB 6 months ago
I figured out the issue. I was kicking off a .vbs file. In the file I was using the shortcuts $(KACE_DEPENDENCY_DIR) which the script did not know only Kace did.
This brings me to my next question, can you run .vbs directly from Kace vs kicking off a file?
The issue is that if you kick off a vbs, your directory will constaintly change based on the job #. For instance, if you kick off a VBS script using $(KACE_DEPENDENCY_DIR)\yourscriptname.vbs, when you go to reference other files, those file cannot be referenced in the script as $(KACE_DEPENDENCY_DIR)\filename. It seems that you have to do a tmp directory of sorts and push the files for Kase to work.
I am simply trying to find a way around that. I hope that helps.
Comments:
-
Glad you figured it out.
You could do -
Launch a program...
Directory: C:\Windows\System32
File: cscript.exe
Parameters: $(KACE_DEPENDENCY_DIR)\prndrvr.vbs -a -m "Canon iR-ADV C5550/5560 UFR II"
But you would have a bunch of 1 liners and I'm not sure how you would evoke the first line of your script, which would probably break the rest of the script. (Set objShell = CreateObject("WScript.Shell"))
Your best option is probably to zip up the 3 vbs files (prndrvr.vbs, prnmngr.vbs, prnport.vbs) into a single file. (for example, print-vbs.zip)
Then do an unzip as the first task.
unzip a file...
Directory: $(KACE_DEPENDENCY_DIR)
File: print-vbs.zip
Target: C:\Temp (make sure this folder exists, or choose a different directory)
Then change your vbs script lines with KACE_DEPENDENCY_DIR to point to that target folder instead and run your script as task 2.
"cscript ""$(KACE_DEPENDENCY_DIR)\Prnport.vbs"" -> "cscript ""C:\temp\Prnport.vbs"" - AmberSDNB 6 months ago