Solved

Printer Login Script Modification?

Posted on 2008-06-23
11
538 Views
Last Modified: 2008-06-25
Experts,

I have this printer script that works perfectly:

REM Add printer
echo Installing [Xerox] on [troy]
RunDll32.EXE printui.dll,PrintUIEntry /in /n "\\troy\4th FL Xerox 7675"
echo Your default printer is [Xerox] on [troy]
REM Add printer
echo Installing [Xerox] on [troy]
RunDll32.EXE printui.dll,PrintUIEntry /in /n "\\troy\Intake Xerox 5030"
echo Your default printer is [Xerox] on [troy]
REM Add printer
echo Installing [Xerox] on [troy]
RunDll32.EXE printui.dll,PrintUIEntry /in /n "\\troy\3rd FL Xerox 7675"
echo Your default printer is [Xerox] on [troy]
rundll32 printui.dll,PrintUIEntry /dn /n"\\appserver\Xerox Copyroom" /q
rundll32 printui.dll,PrintUIEntry /dn /n"\\appserver\Xerox 3rd Floor" /q
rundll32 printui.dll,PrintUIEntry /dn /n"\\appserver\HP Color LaserJet 4650 PCL 6" /q

Is it possible to add extra code that will stop it from running on 1 computer? I have a terminal server that is locked down and when a TS user logs into the terminal server the restrictions stop these printers from being installed but they have to click ok three times to the "you don't have permission" box that pops up at login. I would like to exclude this 1 computer so that they dont get this error.

If this is not possible just let me know. I would like to do this via script.

Thanks!



0
Comment
Question by:cbossert
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 1

Accepted Solution

by:
mastertechnc earned 500 total points
ID: 21851385
change mtnc-02 to the name of your ts-server, to be safe make sure use the same computer name when your run

echo %COMPUTERNAME% from the command line
IF not %COMPUTERNAME%==MTNC-02

(

REM Add printer

echo Installing [Xerox] on [troy]

RunDll32.EXE printui.dll,PrintUIEntry /in /n "\\troy\4th FL Xerox 7675"

echo Your default printer is [Xerox] on [troy]

REM Add printer

echo Installing [Xerox] on [troy]

RunDll32.EXE printui.dll,PrintUIEntry /in /n "\\troy\Intake Xerox 5030"

echo Your default printer is [Xerox] on [troy]

REM Add printer

echo Installing [Xerox] on [troy]

RunDll32.EXE printui.dll,PrintUIEntry /in /n "\\troy\3rd FL Xerox 7675"

echo Your default printer is [Xerox] on [troy]

rundll32 printui.dll,PrintUIEntry /dn /n"\\appserver\Xerox Copyroom" /q

rundll32 printui.dll,PrintUIEntry /dn /n"\\appserver\Xerox 3rd Floor" /q

rundll32 printui.dll,PrintUIEntry /dn /n"\\appserver\HP Color LaserJet 4650 PCL 6" /q

)

Open in new window

0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21851420
The attached will work - just modify the name of the server to the one you wish to exclude (first line of code).
IF %COMPUTERNAME%==TSSERVER GOTO EOF

REM Add printer

echo Installing [Xerox] on [troy]

RunDll32.EXE printui.dll,PrintUIEntry /in /n "\\troy\4th FL Xerox 7675"

echo Your default printer is [Xerox] on [troy]

REM Add printer

echo Installing [Xerox] on [troy]

RunDll32.EXE printui.dll,PrintUIEntry /in /n "\\troy\Intake Xerox 5030"

echo Your default printer is [Xerox] on [troy]

REM Add printer

echo Installing [Xerox] on [troy]

RunDll32.EXE printui.dll,PrintUIEntry /in /n "\\troy\3rd FL Xerox 7675"

echo Your default printer is [Xerox] on [troy]

rundll32 printui.dll,PrintUIEntry /dn /n"\\appserver\Xerox Copyroom" /q

rundll32 printui.dll,PrintUIEntry /dn /n"\\appserver\Xerox 3rd Floor" /q

rundll32 printui.dll,PrintUIEntry /dn /n"\\appserver\HP Color LaserJet 4650 PCL 6" /q

:EOF

Open in new window

0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21851424
lol, must learn to type quicker ;-)
0
 
LVL 12

Expert Comment

by:Serge Fournier
ID: 21851425
use a vbs script to install your printers (on windows 2000+)

you can use the network object to have the name of the person who is logging

ass this to the script:
if usenam="theguy.iwantomapprinter" then
    'add printer here
end if

my whole logon script is in this post:
(in case i forget something, like a object definition)
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/2003_Server/Q_23486974.html


'------------vbs file-----------

'=== network groups (pas le login) avec tous les CN, OU, DC

Set objUser = CreateObject("ADSystemInfo")

Set CurrentUser = GetObject("LDAP://" & objUser.UserName)

 

'=== network usename

usenam = lcase(objNet.UserName)

uselna = lcase(currentuser.sn)         '=== last name

usefna = lcase(currentuser.givenname)  '=== first name
 
 

'=== remark in front, to test script, so error can show up

'on error resume next

 

Set objNet    = CreateObject("WScript.Network") 

 

'=== printer server name

serv01 = "\\printerserver\"

'=== printer name

a = "hpprintername"

'=== server + share name for the drive to map

b = serv01 & a

 

objNet.RemovePrinterConnection b

objNet.AddWindowsPrinterConnection b

 

'=== end of printers

 

 

'=== mapping of network drives done

Open in new window

0
 
LVL 12

Expert Comment

by:Serge Fournier
ID: 21851433
oops i tought you said stopping from one user

anyway my initial script chek for computer name too

you can code a great logon script in vbs
more possibilities than any .bat file
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Expert Comment

by:mastertechnc
ID: 21851465
we use vbs but are moving to perl,
0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21851488
There are situations in which a bat file is more appropriate.  Just as there are situations that Perl makes things easier... the point in languages is that each has their place.

In this case, the original code is a batch file.  The asker says it works well, he would just like a minor change.  As the minor change is adding two lines to the code, it makes sense to stick with the batch file instead of rewriting it in VBS - in my opinion.

Though all my printer installation scripts are also in VBS.
0
 

Author Comment

by:cbossert
ID: 21851531
NICE!! That was all I was looking for and it works great!!

Thank you mastertech!!

Thank you to the rest of you experts for your comments, but this is what I wanted/needed.

cbossert
0
 
LVL 12

Expert Comment

by:Serge Fournier
ID: 21851571
you are right purplepomegranite, this user will accept your solution
since mine is incomplete and will make him work more hehe

but i like to post thoses .vbs files, so poeple can see a wider range of possibilities
it's their call, to use them or not, even though thy should get your solution, by respect


0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21851597
lol, not my solution, I was beaten to it, so quite rightly the points have been given to mastertechnc.

VBS is a very powerful tool - and is one that I use more often than any other.  But you shouldn't underestimate batch... it is a black art that comes into it's own in certain situations. :-)
0
 
LVL 12

Expert Comment

by:Serge Fournier
ID: 21851731
*shiver*

are you trying to get more poeple to the dark side?
yoda would not like you :P
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now