Solved

Microsoft, Windows, XP and Vista, Add Printer scripts

Posted on 2008-10-24
8
915 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

776 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