Gareth McKee
asked on
script to select default printer
Hi all,
background
2003 server
i am trying to get a script to offer the user a choice of which printer to have as their default depending on which office they happen to be. i think i am almost there but it does not work.
Option Explicit
Dim objNetwork, sPrintPath, sLocate
set objNetwork = CreateObject("WScript.Netw ork")
sLocate = InputBox("Which office are you in? Type 'B', 'M', 'N', 'R', 'T'.")
Select Case sLocate
Case "B"
sPrintPath = "\\jjfox1\BombayChicken"
Case "M"
sPrintPath = "\\jjfox1\MeatSamosa"
Case "N"
sPrintPath = "\\Newcastles\Navratan"
Case "R"
sPrintPath = "\\jjfox1\Raita"
Case "T"
sPrintPath = "\\jjfox1\tandoorichicken"
objNetwork.SetDefaultPrint er sPrintPath
WScript.quit
End Select
any help greatly appreciated
thanks
gareth
background
2003 server
i am trying to get a script to offer the user a choice of which printer to have as their default depending on which office they happen to be. i think i am almost there but it does not work.
Option Explicit
Dim objNetwork, sPrintPath, sLocate
set objNetwork = CreateObject("WScript.Netw
sLocate = InputBox("Which office are you in? Type 'B', 'M', 'N', 'R', 'T'.")
Select Case sLocate
Case "B"
sPrintPath = "\\jjfox1\BombayChicken"
Case "M"
sPrintPath = "\\jjfox1\MeatSamosa"
Case "N"
sPrintPath = "\\Newcastles\Navratan"
Case "R"
sPrintPath = "\\jjfox1\Raita"
Case "T"
sPrintPath = "\\jjfox1\tandoorichicken"
objNetwork.SetDefaultPrint
WScript.quit
End Select
any help greatly appreciated
thanks
gareth
Can you not add the default printer automatically depending on which %logonserver% they are authenticating to?
ASKER
hi
SirBounty
currently the script does bring up the question and allows the entry of a choice however it does not actually change the default.
thanks, i will try the change and see what happens.
Mark
sorry shoul have been clearer on the question. i have a complete citrix enironment and ony thin terms on the desktop.
SirBounty
currently the script does bring up the question and allows the entry of a choice however it does not actually change the default.
thanks, i will try the change and see what happens.
Mark
sorry shoul have been clearer on the question. i have a complete citrix enironment and ony thin terms on the desktop.
ASKER
Hi SirBounty
i have copied and pasted your script and tried it.
for some reason only 'T' works.
security is set correctly on all the printers as i do have access to each printer etc
any ideas?
i have copied and pasted your script and tried it.
for some reason only 'T' works.
security is set correctly on all the printers as i do have access to each printer etc
any ideas?
above the select case, place this: (perhaps the response needs to be stripped of any white space)
msgbox "|" & sLocate & "|"
Select Case sLocate
Case "B"
sPrintPath = "\\jjfox1\BombayChicken"
Case "M"
sPrintPath = "\\jjfox1\MeatSamosa"
Case "N"
sPrintPath = "\\Newcastles\Navratan"
Case "R"
sPrintPath = "\\jjfox1\Raita"
Case "T"
sPrintPath = "\\jjfox1\tandoorichicken"
objNetwork.SetDefaultPrint er sPrintPath
msgbox "|" & sLocate & "|"
Select Case sLocate
Case "B"
sPrintPath = "\\jjfox1\BombayChicken"
Case "M"
sPrintPath = "\\jjfox1\MeatSamosa"
Case "N"
sPrintPath = "\\Newcastles\Navratan"
Case "R"
sPrintPath = "\\jjfox1\Raita"
Case "T"
sPrintPath = "\\jjfox1\tandoorichicken"
objNetwork.SetDefaultPrint
ASKER
hi sirbounty,
i have played about with the order of the case " " positions.
it is only ever the last in the list (currently Case"T") which works. if i move B to the last in the order B will work
thanks
gareth
i have played about with the order of the case " " positions.
it is only ever the last in the list (currently Case"T") which works. if i move B to the last in the order B will work
thanks
gareth
Try my last post please, and let me know what it returns...you might also adjust the input line to read:
sLocate = Trim(InputBox("Which office are you in? Type 'B', 'M', 'N', 'R', 'T'."))
sLocate = Trim(InputBox("Which office are you in? Type 'B', 'M', 'N', 'R', 'T'."))
ASKER
sorry
i did try your last post but still not working correctly. working as per my last post.
also
tried the new input line and still the same.
sorry about this mate.
i did try your last post but still not working correctly. working as per my last post.
also
tried the new input line and still the same.
sorry about this mate.
Right - but I need to know what was in that msgbox when you ran it?
ASKER
when msgbox "|" & sLocate & "|" was in the script the initial question box was no different but after selecting and pressing 'ok' a new box popped up with INI for example on it.
when using the new input there was no change from original.
when using the new input there was no change from original.
Use this sub main...
Sub Main
sLocate = ucase(trim(InputBox("Which office are you in? Type 'B', 'M', 'N', 'R', 'T'.")))
If sLocate <> "B" and sLocate <> "M" and sLocate <> "N" and sLocate <> "R" and sLocate <> "T" Then
wscript.echo "You must select a valid choice!"
Main
End If
Select Case sLocate
Case "B"
sPrintPath = "\\jjfox1\BombayChicken"
Case "M"
sPrintPath = "\\jjfox1\MeatSamosa"
Case "N"
sPrintPath = "\\Newcastles\Navratan"
Case "R"
sPrintPath = "\\jjfox1\Raita"
Case "T"
sPrintPath = "\\jjfox1\tandoorichicken"
objNetwork.SetDefaultPrint er sPrintPath
WScript.quit
End Select
End Sub
Sub Main
sLocate = ucase(trim(InputBox("Which
If sLocate <> "B" and sLocate <> "M" and sLocate <> "N" and sLocate <> "R" and sLocate <> "T" Then
wscript.echo "You must select a valid choice!"
Main
End If
Select Case sLocate
Case "B"
sPrintPath = "\\jjfox1\BombayChicken"
Case "M"
sPrintPath = "\\jjfox1\MeatSamosa"
Case "N"
sPrintPath = "\\Newcastles\Navratan"
Case "R"
sPrintPath = "\\jjfox1\Raita"
Case "T"
sPrintPath = "\\jjfox1\tandoorichicken"
objNetwork.SetDefaultPrint
WScript.quit
End Select
End Sub
ASKER
no change. can only select the last in the list
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi SirBounty,
that's the badger!!!!
thanks very mcuh for your help. working like a dream now
gareth
that's the badger!!!!
thanks very mcuh for your help. working like a dream now
gareth
:^)
Happy to help!
Happy to help!
I would modify it to this:
Option Explicit
Dim objNetwork, sPrintPath, sLocate
set objNetwork = CreateObject("WScript.Netw
Main()
wscript.quit
Sub Main
sLocate = InputBox("Which office are you in? Type 'B', 'M', 'N', 'R', 'T'.")
If sLocate <> "B" and sLocate <> "M" and sLocate <> "N" and sLocate <> "R" and sLocate <> "T" Then
wscript.echo "You must select a valid choice!"
Main
End If
Select Case sLocate
Case "B"
sPrintPath = "\\jjfox1\BombayChicken"
Case "M"
sPrintPath = "\\jjfox1\MeatSamosa"
Case "N"
sPrintPath = "\\Newcastles\Navratan"
Case "R"
sPrintPath = "\\jjfox1\Raita"
Case "T"
sPrintPath = "\\jjfox1\tandoorichicken"
objNetwork.SetDefaultPrint
WScript.quit
End Select
End Sub