Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

VBscript - Can I do this?

  • 01-05-2007 9:36am
    #1
    Closed Accounts Posts: 2,460 ✭✭✭


    set objNetwork = CreateObject("WScript.network")
    objNetwork.AddWindowsPrinterConnection "\\pri-fileserver\Accounts printer 1"

    Now if I want to make this script longer by adding in one or two more printers do I need to create a new object everytime with new names (variables). Or can I scapeboat off the top line and add as many second lines as I want for different printers.


    Cheers.


Comments

  • Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭matt-dublin


    yes i use that here as a logon script to ad
    vbscript wrote:

    '
    ' Printer Install
    '

    Dim net
    Set net = CreateObject("WScript.Network")
    net.AddWindowsPrinterConnection "\\server\print1"
    net.AddWindowsPrinterConnection "\\server\print2"
    net.AddWindowsPrinterConnection "\\server\print3"
    net.AddWindowsPrinterConnection "\\server\print4"
    net.AddWindowsPrinterConnection "\\server\print5"

    '
    ' You can add multiple printers and shortcuts
    ' by copying the above data and editing the paths

    '
    'net.SetDefaultPrinter "\\server\print1"
    save it as a .vbs file


  • Closed Accounts Posts: 2,460 ✭✭✭workaccount


    Right and to set my default printer do I just need to uncomment that last line?


  • Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭matt-dublin


    yup

    dunno why i have it commented....

    strange!


  • Closed Accounts Posts: 2,460 ✭✭✭workaccount


    Right my script is set up as a policy on the AD. It's definitely in the correct folder and the gp had been refreshed.

    Its just not coming down to the machines though. Ive tried everything and I simply don't know how to troubleshoot this further.

    If I type the full address to the script located on the server from my workstation in the run box (that was a handful) it will install the printer no bother so the script is defo sound.


  • Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭matt-dublin


    it should be located in user config>windows settings>scripts>logon

    don't put it in computer config startup shutdown section as it won't run


  • Advertisement
  • Closed Accounts Posts: 2,460 ✭✭✭workaccount


    Yeah its in user config alright.


  • Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭matt-dublin


    where are you applying the policy? top level or an OU

    policy needs to be applied to the Users OU (or whereever your users are located in AD)


  • Closed Accounts Posts: 2,460 ✭✭✭workaccount


    where are you applying the policy? top level or an OU

    policy needs to be applied to the Users OU (or whereever your users are located in AD)

    Its being applied to the OU alright.


  • Closed Accounts Posts: 2,460 ✭✭✭workaccount


    Everythings up and running now. Thanks matt.


  • Closed Accounts Posts: 2,460 ✭✭✭workaccount


    Actually ive now run into another little problem.

    Our AD is organized on a business unit level. eg. All accountants are in the "Accounts OU". There are a few accountants desks though and each one has a printer. I want to dish out my policy on an OU level but how will I target the "default printer" groups without modifying the directory?


    By the way I don't think I can really split them up into head accounts, payroll et cetera.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭matt-dublin


    I'm not sure how you could do it without breaking it down into further OUs

    Unless you create user specific login scripts that would call a .vbs file or something to that extent


  • Closed Accounts Posts: 2,460 ✭✭✭workaccount


    hmmm, Is there a way to report back via script through an enviroment variable or something what printers are installed?

    Google doesn't seem to yield any results.


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    I'm not sure what you mean. You mean that you want to set a particular default printer, depending on what OU they're in?


  • Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭matt-dublin


    if what seamus said is the case, just apply another group policy directly to that OU and add a new script


  • Closed Accounts Posts: 2,460 ✭✭✭workaccount


    seamus wrote:
    I'm not sure what you mean. You mean that you want to set a particular default printer, depending on what OU they're in?

    If it was as you said it would be easy.

    Eg. Theres 5 desks with 4 ppl on each desk in accounts and head accountants, payroll etc are mixed between the desks. Each desk has a printer. Users are authenticated through AD and all ppl in the department are in the "one" OU.

    With the script which is run on this AU, default printer won't work as theres five printers between all those users and I can't use "define more OU's" in this case as there mixed. The only solution that way would be to define ppl in the AD according to where they sit which probably isn't worth doing for the sake of printer scripts.

    Im hoping there may be some david blane stuff built into windows for dealing with these sort of problems.


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    You could go for the messy, convoluted way.

    Define a security group for each printer. Insert the relevant users into the group corresponding to the printer they should be connected to.

    Then in the logon script, determine which group the user is a member of, and define their default printer that way.

    Horrible and painful. Easier and less trouble stricken to put a big sign on the printer saying, "This is Printer X, make it your default printer by ...."


  • Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭matt-dublin


    if there's only four of them create an individual logon script for each and put it into ad users & computers. Easier than multiple group policies.

    Thats most likely the quickest way to make it work.


  • Closed Accounts Posts: 2,460 ✭✭✭workaccount


    Actually, I must check this out.

    Perhaps if I leave a default printer undefined in my script and let users select the default printer manually, it should remember the user defined default printer upon re-logon.

    Im sure the users wouldn't mind just setting it themselves.


Advertisement