Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
Trouble with running a VBS within a VBS for Printer setups
Logged in as: Guest
arrSession:exec spGetSession 2,2,55994
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
WSH & Client Side VBScript
>> Trouble with running a VBS within a VBS for Printer setups
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
Trouble with running a VBS within a VBS for Printer setups -
1/25/2008 10:27:41 AM
yo_bee
Posts: 2
Score: 0
Joined: 1/24/2008
Status:
offline
I am new to this forum. So I want to just introduce myself.
I am very new to scripting. I always depended on the GUI. Then I started to play around with scripts to help myself administer my network.
So here is my code I am having troube with it. Its using the prnport.vbs, prndrvr.vbs and prnmngr.vbs that is included with XP
I was able to get the prnport.vbs and I think I got the prndrvr.vbs to work, but the prnmngr.vbs is giving an error at the first char line 59
[/size] [size=2]'this script will help install Direct Printing to TCP/IP printers [/size][size=2] [/size][size=2]Servername = Inputbox ("Please enter a name of a server that has the drivers on it:","Enter Server Name") [/size][size=2]'The next line is for testing the server path [/size][size=2]'wscript.echo "\\" & Servername & "\printer\drivers\4100\ps" [/size][size=2] [/size] [size=2]' This part seems to work fine since its one continious text bewteen the " " [/size][size=2]'***************************************************************************************** [/size][size=2]'This part will create the ports for all the IP-Address [/size][size=2]strport1 = "cscript c:\windows\system32\prnport.vbs -a -r MailColor -h 192.168.1.47 -o raw -n 9100 -me -y public -i 1" [/size][size=2]strport2 = "cscript c:\windows\system32\prnport.vbs -a -r Mail1 -h 192.168.1.48 -o raw -n 9100 -me -y public -i 1" [/size][size=2]strport3 = "cscript c:\windows\system32\prnport.vbs -a -r MailCopier -h 192.168.1.40 -o raw -n 9100 -me -y public -i 1" [/size][size=2]strport4 = "cscript c:\windows\system32\prnport.vbs -a -r Printer1 -h 192.168.1.46 -o raw -n 9100 -me -y public -i 1" [/size][size=2]strport5 = "cscript c:\windows\system32\prnport.vbs -a -r Printer2 -h 192.168.1.49 -o raw -n 9100 -me -y public -i 1" [/size][size=2]strport6 = "cscript c:\windows\system32\prnport.vbs -a -r Printer3 -h 192.168.1.93 -o raw -n 9100 -me -y public -i 1"[/size] [size=2] Set WshShell = CreateObject("Wscript.Shell") [/size][size=2] wshshell.run(strport1),0,true [/size][size=2] wshshell.run(strport2),0,true [/size][size=2] wshshell.run(strport3),0,true [/size][size=2] wshshell.run(strport4),0,true [/size][size=2] wshshell.run(strport5),0,true [/size][size=2] wshshell.run(strport6),0,true [/size][size=2]'*****************************************************************************************[/size] [size=2] Set WshShell = CreateObject("Wscript.Shell") [/size][size=2]'***************************************************************************************** [/size][size=2]'This part will install the drivers needed for the printers [/size][size=2]'cscript c:\windows\system32\prndrvr.vbs -a -m "HP LaserJet 4100 PS" -v 3 -h "\\" & Servername & "\printer\drivers\4100\ps" -i "\\" & Servername & "\drivers\4100\PS\hp4100ps.inf" [/size][size=2]'cscript c:\windows\system32\prndrvr.vbs -a -m "HP LaserJet 4100 PCL 5e" -v 3 -h "\\" & Servername & "\printer\drivers\4100\pcl" -i "\\" & Servername & "\drivers\4100\pcl\hp4100p5.inf" [/size][size=2]'cscript c:\windows\system32\prndrvr.vbs -a -m "HP LaserJet 4200 PS" -v 3 -h "\\" & Servername & "\printer\drivers\4200\ps" -i "\\" & Servername & "\drivers\4200\ps\hpc4200d.inf" [/size][size=2]'cscript c:\windows\system32\prndrvr.vbs -a -m "HP LaserJet 4200 PCL 5e" -v 3 -h "\\" & Servername & "\printer\drivers\4200\pcl" -i "\\" & Servername & "\drivers\4200\pcl\hpc4200b.inf" [/size][size=2]strdrvr1 = "cscript c:\windows\system32\prndrvr.vbs -a -m " & "HP LaserJet 4350 PS" & " -v 3 -h " & "\\" & Servername & "\printer\drivers\4350\ps" & " -i " & "\\" & Servername & "\drivers\4350\ps\hpc4x50d.inf" [/size][size=2]'wscript.echo strdrvr1 [/size][size=2]wshshell.run(strdrvr1),1,true [/size][size=2]if error = 0 then [/size][size=2]wscript.echo "Drivers Installed" [/size][size=2]else [/size][size=2]wscript.echo "Drivers Install Failed" [/size][size=2]end if[/size] [size=2]'wshshell.run(cscript prndrvr.vbs -a -m "HP LaserJet 4350 PCL 5e" -v 3 -h "\\" & Servername & "\printer\drivers\4350\pcl" -i "\\" & Servername & "\drivers\4350\pcl\hpc4x50b.inf"),1,true [/size][size=2]'cscript c:\windows\system32\prndrvr.vbs -a -m "HP Color LaserJet 4700 PS" -v 3 -h "\\" & Servername & "\printer\drivers\4700\ps" -i "\\" & Servername & "\drivers\4700\ps\Driver\hpc4700d.inf" [/size][size=2]'cscript c:\windows\system32\prndrvr.vbs -a -m "HP Color LaserJet 4700 PCL 5c" -v 3 -h "\\" & Servername & "\printer\drivers\4700\pcl" -i "\\" & Servername & "\drivers\4700\pcl\Driver\hpc4700b.inf"[/size] [size=2]'***************************************************************************************** [/size][size=2]Set WshShell = CreateObject("Wscript.Shell") [/size][size=2]'***************************************************************************************** [/size][size=2]'This part will install the printers to the proper ports created in an early step [/size][size=2]'cscript prnmngr.vbs -a -p MailColor -m "HP Color LaserJet 4700n" -r MailColor [/size][size=2]'cscript prnmngr.vbs -a -p Mail1 -m "HP LaserJet 4200dtn" -r Mail1 [/size][size=2]'cscript prnmngr.vbs -a -p MailCopier -m "Cannon imageRunner 7095" -r MailCopier [/size][size=2]'cscript prnmngr.vbs -a -p Printer1 -m "HP LaserJet 4100n" -r Printer1 [/size][size=2]'cscript prnmngr.vbs -a -p Printer2 -m "HP LaserJet 4100n" -r Printer2 [/size][size=2]strmngr1 = "cscript c:\windows\system32\prnmngr.vbs -a -p Printer3 -m " & "HP LaserJet 4350 PS" & " -r Printer3" [/size][size=2]wscript.echo strmngr1 [/size][size=2]wshshell.run(strmngr1),1,true 'Here is were I am having trouble. Error "The system cannot find the file specified, Code 80070002, Source (null) [/size][size=2]'***************************************************************************************** [/size][size=2]
Can someone please tell me what I am missing here
If I run cscript prndrvr.vbs -a .......... in a bat file it works, but I can not get the vbs with the parameters to run properly
Post #: 1
RE: Trouble with running a VBS within a VBS for Printer... -
1/25/2008 4:32:14 PM
dm_4ever
Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status:
offline
I'm guessing you haven't seen the frequently asked stuff post....
strmngr1 = "cscript c:\windows\system32\prnmngr.vbs -a -p Printer3 -m " &
Chr(34)
& "HP LaserJet 4350 PS" &
Chr(34)
& " -r Printer3"
Whenever using .Run you need to account for the extra " where needed....you can do it like it is shown above or
strmngr1 = "cscript c:\windows\system32\prnmngr.vbs -a -p Printer3 -m " &
"""
HP LaserJet 4350 PS
"""
& " -r Printer3"
or
insert a function like this somewhere in your script
Function AddQuotes(strText)
AddQuotes = Chr(34) & strText & Chr(34)
End Function
and then use this:
strmngr1 = "cscript c:\windows\system32\prnmngr.vbs -a -p Printer3 -m " &
AddQuotes(
"HP LaserJet 4350 PS"
)
& " -r Printer3"
_____________________________
dm_4ever
My philosophy:
K.I.S.S - Keep It Simple Stupid
Read Me:
http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff:
http://www.visualbasicscript.com/m_47117/tm.htm
(in reply to
yo_bee
)
Post #: 2
RE: Trouble with running a VBS within a VBS for Printer... -
1/26/2008 12:31:05 AM
yo_bee
Posts: 2
Score: 0
Joined: 1/24/2008
Status:
offline
Thank you for your help.
I will try this Monday.
And yes I did not read the FAQ section.
(in reply to
yo_bee
)
Post #: 3
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
WSH & Client Side VBScript
>> Trouble with running a VBS within a VBS for Printer setups
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI