dim argv, CRLF, dsObj, dsRoot, rc, usrObj, wshShell, xlFile, xlObj >CRLF = Chr(13) & Chr(10) >dsRoot = "WinNT://LAB" > >set wshShell = Wscript.CreateObject("Wscript.Shell") >rc = wshShell.Popup("This sample script add users to a NT 4.0 SAM DB." & _ > CRLF & "Continue?", _ > 60, _ > "WSH Sample", _ > vbYesNo + vbQuestion) >If rc <> vbYes Then > Wscript.Quit(1) >End If > >set argv = Wscript.Arguments >If argv.Count = 0 Then > xlFile = InputBox("Enter the path and filename to the Excel " & _ > "spreadsheet containing the list of users to add:") >Else > xlFile = argv.Item(0) >End If > >If xlFile = "" Then > rc = wshShell.Popup("Script error. No input file specified.", _ > 10, _ > "WSH Sample", _ > vbOKOnly + vbExclamation) > Wscript.Quit(1) >End If > >set xlObj = Wscript.CreateObject("EXCEL.application") >xlObj.Visible = True >xlObj.workbooks.open(xlFile) >xlObj.sheets("AddUsers").Activate >xlObj.ActiveSheet.range("A2").Activate > >set dsObj = GetObject(dsRoot) > >Do While xlObj.activecell.Value <> "" > set usrObj = dsObj.Create("user", xlObj.activecell.Value) > > usrObj.FullName = xlObj.activecell.offset(0,1).Value + " " + _ > xlObj.activecell.offset(0,2).Value > usrObj.Description = xlObj.activecell.offset(0,3).Value > usrObj.HomeDirectory = xlObj.activecell.offset(0,4).Value + _ > xlObj.activecell.Value > usrObj.LoginScript = xlObj.activecell.offset(0,5).Value > usrObj.Profile = xlObj.activecell.offset(0,6).Value + _ > xlObj.activecell.Value + ".usr" > > usrObj.SetInfo > > set usrObj = Nothing > xlObj.activecell.offset(1, 0).Activate >Loop > >xlObj.application.quit >rc = wshShell.Popup("Script completed successfully.", _ > 10, _ > "WSH Sample", _ > vbOKOnly + vbInformation) >Wscript.Quit(0) >