Solved

Microsoft, Windows, XP and Vista, Add Printer scripts

Posted on 2008-10-24
8
919 Views
Last Modified: 2012-05-05
Hi,
I have scripts that add printers to user prfiles when they log in. It works in XP but not Vista. I looked though other EE postings etc.. and the script needs to be elevated to administrator level in order to add the printer, kind of like you cannot ipconfig  /release % /renew unless you are in admin cmd. Some others are local adminsistrators and others are not.

I cannot get the script to elevate the permission to add the printer.
Below is a copy of one of the scipts that works in XP.
-------------------------------------------------------------------------
Option Explicit
Dim objNetwork, strUNCPrinter
strUNCPrinter = "\\oatlands-dc\ResourceRoom"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection strUNCPrinter

WScript.Quit

----------------------------------------------------------------------------------

Can anyone help?
0
Comment
Question by:nostrasystems
  • 5
8 Comments
 
LVL 7

Expert Comment

by:maze-uk
ID: 22795082
Is it a script the user runs manually, or via GPO?
0
 

Author Comment

by:nostrasystems
ID: 22796868
Hi, It is ran using a logon batch file in their AD account.
0
 
LVL 7

Expert Comment

by:maze-uk
ID: 22812008
Microsoft technet Script Elevation PowerToys for Windows Vista :
http://technet.microsoft.com/en-us/magazine/cc162321.aspx

That should fix your issue.
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 7

Expert Comment

by:maze-uk
ID: 22812050
Found on another forum (techarena):

With Vista you need to know about: a) the creation and use of limited access tokens by a user who is a local admin, b) the task scheduler, and 3) modifying launchapp.wsf for each GPO initiated at logon.

1.      If your user is a local admin, then the existing GPO logon script you have wont work. Your logon scripts should work for non-local admins.

2.      Your existing logon script wont work for a local admin because your local admin has to receive a limited user token to map drives. Per AdamV http://www.gpanswers.com/community/viewtopic.php?p=5625#5625 Im summarizing his post here: Group Policy and logon scripts process using the elevated user token, and the desktop and all subsequent processes use the limited token. Windows restricts processes started with a limited token from the ability to share information with processes started with the elevated token.

3.      The workaround is to run a launchapp.wsf script which will give your local admin a limited access token so the mapping of drives is done at a protected level, instead at an admin level. Remember in Vista even though you log in as Local Admin you are not running everything at an Admin level. (To run programs at an admin level you right click the *.exe and choose run as admin.) LaunchApp.wsf is easy to use.

4.      After you get LaunchApp.wsf working with your script you will want to edit the script and comment out the lines that create annoying dialog box. Comment out the following lines: WScript.Echo "Task definition created. About to submit the task." and   WScript.Echo "Task submitted for all drives."

5.      WAIT  DONT Stop Here, you have to know about the new functionality with Task Scheduler!   In order to launch your mapped drive logon script LaunchApp.wsf schedules a job to run your GPO logon script with that limited token I was talking about.

6.      So why was it important to know about Task Scheduler? Because the LaunchApp.wsf created a scheduled job called "Launch App As Interactive User" and if you have LaunchApp.wsf being used for several GPOs it will choke on itself in the Task Scheduler because to the OS it looks like your creating several scheduled jobs with the same name.

7.      So how do I run several GPOs that have to invoke LaunchApp.wsf to run? At first I modified my logon script GPO, to run logon scripts synchronously. This worked because it forces LaunchApp.wsf to launch and complete one scheduled job at a time. The negative: it takes longer for users to logon in synchronous mode.

8.      To get out of having to use Logon Script Synchronous Mode, open up LaunchApp.wsf and look again for the line strTaskName = "Launch App As Interactive User" and add the name of the GPO your trying to run to the end of the name. So the line would look like strTaskName = "Launch App As Interactive User  Mapped drives for Programming Dept". This causes each GPO that uses LaunchApp.wsf to create its own scheduled task with its own name. It also makes it easier to see what is happening in the new Task Scheduler Event log.

9.      Lastly, obviously you only have to run launchapp.wsf for Vista Clients. Now you could create a WMI filter that states SELECT * from Win32_OperatingSystem WHERE Caption LIKE "%Vista%" But I found it nicer to not have to apply a filter by running LaunchApp2.wsf found at Michaels Zills blog at http://www.enterprisedev.org//blogs/michael/archive/2007/01/ 05/deploying-group-policy-using-vista.aspx This allows you to create one GPO that will apply to both XP and Vista Clients.
0
 
LVL 7

Accepted Solution

by:
maze-uk earned 500 total points
ID: 22812059
sorry, my last post was found here:
http://mcpmag.com/forums/forum_posts.asp?tid=3604&pn=1
0
 
LVL 7

Expert Comment

by:maze-uk
ID: 22812109
... and last: Deploying Group Policy Using Windows Vista (http://technet.microsoft.com/en-us/library/cc766208.aspx).
there is a section  "Group Policy Scripts can fail due to User Account Control" with a workaroud:
To configure launchapp.wsf to postpone the execution of a logon script
1 Copy the logon script and the launchapp.wsf script to a network share.
2 Start Group Policy Management Console (GPMC). In GPMC, right-click the GPO you want to modify, and then click Edit.
3 In the User Configuration node, expand Windows Settings, and then click Scripts.
4 Right-click Logon, and then click Properties.
5 In the Logon Properties dialog box, click Add.
6 In the Script Name box, type launchapp.wsf
7 In the Script Parameters box, type the full path and name to logon.bat



0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

831 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