Athenaeum Posted May 31, 2007 Share Posted May 31, 2007 Hi Everyone,First and foremost I am a noob to programming but I need some help. I am working on a loginscript and I have it running with no syntax errors finally. I have created a active directory securitygroup called test and put my user into this group, I also put him in a test OU. The problem is thescript 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 NextstrComputer = "."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.ScreenHeightNextSet objExplorer = CreateObject _ ("InternetExplorer.Application")objExplorer.Navigate "about:blank" objExplorer.ToolBar = 0objExplorer.StatusBar = 0objExplorer.Left = (intHorizontal - 400) / 2objExplorer.Top = (intVertical - 200) / 2objExplorer.Width = 400objExplorer.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.UserNameSet 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 IfWscript.Sleep 10000objExplorer.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 10000objExplorer.QuitGreg Link to comment Share on other sites More sharing options...
IcemanND Posted May 31, 2007 Share Posted May 31, 2007 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 More sharing options...
Athenaeum Posted June 1, 2007 Author Share Posted June 1, 2007 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 howdo 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 More sharing options...
FrankE9999 Posted June 1, 2007 Share Posted June 1, 2007 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 HTAsIntroduction to HTML Applications A little more advances example shows what you can do with an HTAHTA-Notepad Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now