Install printers based on logged on computer

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
penyel
Newbie
Posts: 3
Joined: Fri Jan 12, 2007 4:32 pm

Install printers based on logged on computer

Post by penyel » Fri Jan 12, 2007 4:46 pm

I am currentlly trying to install printers for different sections of the office, and set the correct one as the default. However I need to define a method were I can get the a computer name and compare it against a list of names to define which printers will be installed.

So far I created a script which install a set of printers on a given machine if a folder exists under the C:\windows\system32 folder. I believe this is too labor intensive and hinders the whole purpose of scripting.

Any help will be greatly appreciated. Here is what I have so far

IfFileExists>C:\Windows\System32\SectionA\SectionA.bat
label>execute
Run Program>C:\Windows\System32\rundll32 printui.dll,PrintUIEntry /dn /q /n \\cpasb\7thFloor
Run Program>rundll32 printui.dll,PrintUIEntry /dn /q /n \\cpasb\7thFloorNewArea
Run Program>rundll32 printui.dll,PrintUIEntry /dn /q /n \\cpasb\BostonAdmin
Run Program>rundll32 printui.dll,PrintUIEntry /dn /q /n \\Cpasb\LaserJet4050
Run Program>rundll32 printui.dll,PrintUIEntry /in /q /n \\BOS-Printers\7thFloor
Run Program>rundll32 printui.dll,PrintUIEntry /in /q /n \\BOS-Printers\7thFloorNewArea
Run Program>rundll32 printui.dll,PrintUIEntry /in /q /n \\BOS-Printers\LaserJet4050
Run Program>rundll32 printui.dll,PrintUIEntry /y /n \\Bos-Printers\7thFloorNewArea
Goto>execute

Else
IfFileExists>C:\Windows\System32\SectionB\SectionB.bat
label>executeB
Run Program>C:\Windows\System32\rundll32 printui.dll,PrintUIEntry /dn /q /n \\cpasb\7thFloor
Run Program>rundll32 printui.dll,PrintUIEntry /dn /q /n \\cpasb\7thFloorNewArea
Run Program>rundll32 printui.dll,PrintUIEntry /dn /q /n \\cpasb\BostonAdmin
Run Program>rundll32 printui.dll,PrintUIEntry /dn /q /n \\Cpasb\LaserJet4050
Run Program>rundll32 printui.dll,PrintUIEntry /in /q /n \\BOS-Printers\7thFloor
Run Program>rundll32 printui.dll,PrintUIEntry /in /q /n \\BOS-Printers\7thFloorNewArea
Run Program>rundll32 printui.dll,PrintUIEntry /in /q /n \\BOS-Printers\LaserJet4050
Run Program>rundll32 printui.dll,PrintUIEntry /y /n \\BOS-Printers\7thFloor
Goto>executeB

Else
IfFileExists>C:\Windows\System32\SectionC\SectionC.bat
label>executeC
Run Program>C:\Windows\System32\rundll32 printui.dll,PrintUIEntry /dn /q /n \\cpasb\7thFloor
Run Program>rundll32 printui.dll,PrintUIEntry /dn /q /n \\cpasb\7thFloorNewArea
Run Program>rundll32 printui.dll,PrintUIEntry /dn /q /n \\cpasb\BostonAdmin
Run Program>rundll32 printui.dll,PrintUIEntry /dn /q /n \\Cpasb\LaserJet4050
Run Program>rundll32 printui.dll,PrintUIEntry /in /q /n \\BOS-Printers\7thFloor
Run Program>rundll32 printui.dll,PrintUIEntry /in /q /n \\BOS-Printers\7thFloorNewArea
Run Program>rundll32 printui.dll,PrintUIEntry /in /q /n \\BOS-Printers\LaserJet4050
Run Program>rundll32 printui.dll,PrintUIEntry /y /n \\BOS-Printers\LaserJet4050
Goto>executeC

Endif

    User avatar
    Marcus Tettmar
    Site Admin
    Posts: 7395
    Joined: Thu Sep 19, 2002 3:00 pm
    Location: Dorset, UK
    Contact:

    Post by Marcus Tettmar » Fri Jan 12, 2007 4:51 pm

    To get the computer name just look at the COMPUTER_NAME variable:

    E.g. this will show you the computer name:

    MessageModal>COMPUTER_NAME

    So you could have a list of names in a text file, or array, or database, or (I don't know - where is this list of names already?) and simply compare each one to COMPUTER_NAME. Add add the logic accordingly.
    Marcus Tettmar
    http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

    Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

    Post Reply
    Sign up to our newsletter for free automation tips, tricks & discounts