?
Solved

Problems Getting New Logon Script & New GPO to Work

Posted on 2006-05-11
10
Medium Priority
?
393 Views
Last Modified: 2010-04-18
I have a new logon script I am trying to get to run when a user logs onto the domain.  The script works fine when I run it locally on a computer.  However when I try to have it run by group policy from the DC it does not work.  No errors are generated on the server or computer (that I can tell).

Here is what I have done (server side & PC side):

- Created a new GPO and linked it to my domain.

- Added a test user to the Security Filtering section for this new policy to be enforced on him.

- Copied my new script and its corresponding files to the c:\winnt\sysvol\domain\policies\{GUID}\user\scripts\logon folder.

- On the new policy under: User Configuration – Windows Settings – Scripts – Logon . . . I have the new script added under scripts.

- Ran gpupdate /force on the target PC.  Also rebooted the PC after that failed.

Here is the new script – it is a network printer script:

'******************************************************************************
'******************************************************************************
'**          Printer mapping
'******************************************************************************
'******************************************************************************
on error resume next
Dim objGroupList, objUser, objShell, strGroup, objNet, strNTName
Dim strNetBIOSDomain, strHomeDrive, strHomeShare, CurrentUser, aPrinter, x
Dim PrnList, fso, WshShell, WshNetwork, PrinterPath, LogonPath, strGroup1
Dim strUserName, Return
const fsoForReading = 1

Set objNet = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
LogonPath = fso.GetParentFolderName(WScript.ScriptFullName)

call Delprinters
call Mapprinters

'************
'Remove Printers
'************
sub Delprinters()
Dim errorObject
'Set errorObject = CreateObject("Wscript.Error") <-> I disabled this for another issue.
If fso.FileExists(LogonPath & "\Printers_remove.csv") Then
  Set prnlist = fso.OpenTextFile(logonpath & "\Printers_remove.csv", fsoForReading)
  aPrinter = Split(prnlist.Readall,vbcrlf)
For x = 0 to UBound(aPrinter)
  PrinterPath = aPrinter(x)
  objNet.RemovePrinterConnection PrinterPath, true
  'DisplayErrorInfo
Next
  'Wscript.Echo "Done. Removed " & x & " Printers"
end if
End Sub

'*************
'add printers
'*************

sub Mapprinters()
If fso.FileExists(LogonPath & "\Printers_add.csv") Then
  Set prnlist = fso.OpenTextFile(logonpath & "\Printers_add.csv", fsoForReading)
  aPrinter = Split(prnlist.Readall,vbcrlf)
For x = 0 to UBound(aPrinter)
  PrinterPath = aPrinter(x)
  objNet.AddWindowsPrinterConnection PrinterPath
Next
  'Wscript.Echo "Done. Mapped " & x & " Printers"

'******************************************************************************
'******************************************************************************
'**          Printer default selection box
'******************************************************************************
'******************************************************************************
Title = "Pick a Default Printer"
Text = "A new server as been put in place and I need you to choose your preferred printer. Listed below are the printers currently available to you.  Please enter the number that is next to the printer you prefer to have as your default printer.  The first number is 0 and goes through 11 or so. Please select a number accordingly" & vbCrLf & vbCrLf
Set oPrnEnum = objNet.EnumPrinterConnections
j = oPrnEnum.Count
For i = 0 To j - 1 Step 2
    Text = Text & (i/2) & vbTab
    Text = Text & oPrnEnum(i) & vbCrLF & oPrnEnum(i+1) & vbCrLf
    Next
tmp = InputBox(Text, "Company Default printer selector", 0)
If tmp = "" Then
    WScript.Echo "No user input, aborted"
    WScript.Quit
End If
tmp = CInt(tmp)
If (tmp < 0) Or (tmp > (j/2 - 1)) Then
    WScript.Echo "Wrong value, aborted"
    WScript.Quit
End If
printer = oPrnEnum(tmp*2 + 1)
objNet.SetDefaultPrinter printer
MsgBox "Thank you, your default printer has been successfully set to " & printer, _
        vbOKOnly + vbInformation, Title

End If
End Sub
Set objGroupList = Nothing
Set objUser = Nothing
Set objNet = Nothing      
Set fso = nothing
Set objShell = nothing
'msgbox "Logon Script Completed"

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

Here are the contents of the files it references:

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

Printers_remove.csv

\\print\printer1
\\print\printer2
\\print\printer3

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

Printers_add.csv

\\print1\printer1
\\print1\printer2
\\print1\printer3

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

Any help or advice will be greatly appreciated.
0
Comment
Question by:dmcoop
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 48

Assisted Solution

by:Jay_Jay70
Jay_Jay70 earned 300 total points
ID: 16663444
Hi dmcoop,

try it this way, add the script to the user profile under the profile tab - logon script

then copy the script to c:\windows\sysvol\sysvol\domainname\scripts

see if runs now
0
 
LVL 3

Author Comment

by:dmcoop
ID: 16663455
I'll try that . . . however . . . I don't want to have to go through every users profile (or at least the ones at this location) to get this to work.  I'll do it as a troubleshooting step to see what happens.

I'm sorry I didn't make that clear.  I really want to get this thing to run out of a GPO.

Thanks!
0
 
LVL 3

Author Comment

by:dmcoop
ID: 16663470
Oh and for some background on this you can click on the link below:

http://www.experts-exchange.com/Operating_Systems/Windows_Server_2003/Q_21846990.html

The above link takes you to the post I made to help get a good script file.  I like the script a lot . . . it does almost all that I want it to do and after I have all the old printers removed it will be perfect.  This may bring some context to what I am trying to do here.  We are rolling out a new print server and want to delete all the old printers and install all the new ones without having to touch each machine.

0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 48

Expert Comment

by:Jay_Jay70
ID: 16663645
ahhh i see, thats a cool script!

when you set the script through the policy, and its applied, can you run a gpresult and make sure that the clients are actually picking up the policy
0
 
LVL 51

Expert Comment

by:Netman66
ID: 16663797
You don't have to go through everyone's account in AD.  Simply select all the accounts you want to use it (like you would multiple files), any common attributes can be changed all at once.

0
 
LVL 3

Author Comment

by:dmcoop
ID: 16667930
ok.  The gpresult shows that the policy is being applied to the test user . . . so . . . I have to assume something in the way the script is working is having a problem.

I'm gonna break the script down to a more basic script and see what happens.

I'll post back in a few.
0
 
LVL 12

Accepted Solution

by:
Mazaraat earned 1200 total points
ID: 16669127
Howdy again =)

In your policy where are you assigning the script?  It should be under:

 USER CONFIGURATION//WINDOWS SETTINGS//SCRIPTS//LOGON

when you add the file in, click show files button, it will open the script repository folder for the policy, paste your script in the folder.  Then click on the Add button and supply the name of the script you want to use =)


Where is the policy linked to?  Download the group policy manger:
http://www.microsoft.com/downloads/details.aspx?FamilyID=0a6d4c24-8cbd-4b35-9272-dd3cbfc81887&DisplayLang=en

create an OU and move the test user to it, link the GPO to the new OU you created.  At the PC start->run->gpupdate /force

now logout and logon...does it run?
0
 
LVL 12

Expert Comment

by:Mazaraat
ID: 16669139
rewrite:

In your policy where are you assigning the script?  It should be under:

 USER CONFIGURATION//WINDOWS SETTINGS//SCRIPTS//LOGON

when you open the script logon/logoff properties, click show files button, it will open the script repository folder for the policy, paste your script in the folder.  Then click on the Add button and supply the name of the script you want to use =)
0
 
LVL 3

Author Comment

by:dmcoop
ID: 16669477
All right got it working through Group Policy Management.

I never could get it working through ADUC (user's profile).  

Anyway, here is what I did.

I used the gpresult tool to make sure the policy was being picked up by the PC.  It was.  I then created a small .vbs test script to make sure that the scripts would run and I dropped that into the USER CONFIGURATION//WINDOWS SETTINGS//SCRIPTS//LOGON portion the policy.  It did not work.  

So . . . I wondered if perhaps it is some type of replication problem . . . and found a decent script to force replication of all DCs.  After running that script I tried again it it worked.

Then I replaced the test script with the real one and tried it.  It did not work.  I did the force replication script again and then the logon script ran perfectly.

I think I must have another problem with replication or something.  I'm gonna start trouble shooting that now.

I'll be splitting the points between Jay_Jay70 and Mazaraat since their post helped me get to a point where I could trouble shoot and to confirm if I was setting things correctly.
0
 
LVL 12

Expert Comment

by:Mazaraat
ID: 16669485
Thanks, glad we could help.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Organizations create, modify, and maintain huge amounts of data to help their businesses earn money and generally function.  Typically every network user within an organization has a bit of disk space to store in process items and personal files.   …
I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
Integration Management Part 2
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

864 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