Jump to content

Help with Login Script


Recommended Posts

Hi Everyone,

First and foremost I am a noob to programming but I need some help. I am working on a login

script and I have it running with no syntax errors finally. :) I have created a active directory security

group called test and put my user into this group, I also put him in a test OU. The problem is the

script will map the home directory but will not complete the printer mapping or the drive mapping. Here is the code, thanks for the help.

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("Winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next

Set objExplorer = CreateObject _
("InternetExplorer.Application")

objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Left = (intHorizontal - 400) / 2
objExplorer.Top = (intVertical - 200) / 2
objExplorer.Width = 400
objExplorer.Height = 200
objExplorer.Visible = 1

objExplorer.Document.Body.Style.Cursor = "wait"

objExplorer.Document.Title = "Testing"
objExplorer.Document.Body.InnerHTML = "The <b>Test, Inc</b> logon script is being processed. " _
& "This might take several minutes to complete."

Const ENGINEERING_GROUP = "cn=engineering"
Const FINANCE_GROUP = "cn=finance"
Const HUMAN_RESOURCES_GROUP = "cn=human resources"
Const TEST_ = "cn=test"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:","\\datastore\Users\" & wshNetwork.UserName


Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, ENGINEERING_GROUP) Then

wshNetwork.MapNetworkDrive "g:","\\FileServer\Engineering\"
wshNetwork.AddWindowsPrinterConnection "\\PrintServer\EngLaser"
wshNetwork.AddWindowsPrinterConnection "\\PrintServer\Plotter"


ElseIf InStr(strGroups, FINANCE_GROUP) Then

wshNetwork.MapNetworkDrive "g:","\\FileServer\Finance\"
wshNetwork.AddWindowsPrinterConnection "\\PrintServer\FinLaser"

ElseIf InStr(strGroups, TEST_) Then

wshNetwork.MapNetworkDrive "g:","\\datastore\decostar all\"
wshNetwork.AddWindowsPrinterConnection "\\decos106\main01"

ElseIf InStr(strGroups, HUMAN_RESOURCES_GROUP) Then

wshNetwork.MapNetworkDrive "g:","\\FileServer\Human Resources\"
wshNetwork.AddWindowsPrinterConnection "\\PrintServer\HrLaser"
wshNetWork.SetDefaultPrinter "\\PrintServer\HrLaser"

End If

Wscript.Sleep 10000

objExplorer.Document.Body.InnerHTML = "Your logon script is now complete. Should you need assistance, please contact the Helpdesk at 770-555-5555"

objExplorer.Document.Body.Style.Cursor = "default"

Wscript.Sleep 10000

objExplorer.Quit

Greg

Link to comment
Share on other sites


if you remove the 'On Error Resume Next' do you get errors? Does it work if you run it manually rather than as a login script?

Why not run this as an HTA rather than create an IE nstance to post messages to?

Link to comment
Share on other sites

if you remove the 'On Error Resume Next' do you get errors? Does it work if you run it manually rather than as a login script?

Why not run this as an HTA rather than create an IE nstance to post messages to?

I finally got it working after making some adjustments. I am not familiar with HTA, what is it and how

do I do it? The only requires is it must work on Windows 2000 and XP machines.

Thanks,

Greg

Link to comment
Share on other sites

Writing an HTA is similar to writing a Web page. The big advantage is that an HTA application doesn't have the security restrictions that a web page would so anything you can do from a script you can do from an HTA. The thing you have to remember is that unlike a web page there isn't a server to do any processing so you have to do everything using a scripting and the document object model.

Here are some links

Creating Your Own HTAs

Introduction to HTML Applications

A little more advances example shows what you can do with an HTA

HTA-Notepad

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...