Login | |
|
 |
Re: noobie needs help with first script :? - 1/8/2005 12:02:27 PM
|
|
 |
|
| |
tnoonan
Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
|
Here you go. Edited from another script I had to change admin password on local box all pc's on domain. You should have one local account on every box that is the same. Here i'm using Administrator account. Just make sure you change the email settings at the end. '------------------------------------------------------------------------------- ' Initialization - Declare variables '------------------------------------------------------------------------------- Dim MyVar Dim objOutlook Dim objNameSpace Dim mItem Dim strCarbonCopy Dim strBCC Dim strReceipient Dim strSubject Dim strBodyText Dim strMsg Dim pAttachment Dim strAttach Dim DnameObj,objContainer,colPCs,objEnv,objDomain Dim isnew,fso dim message,dname Dim fsoIn,fsoOut Dim inFile,outFile,outExist,outExist2 Dim arrComputerNames Dim objUser Dim strComputer Dim ErrorOccurred Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Const inFilename = "PCList.txt" Const outFileExist = "PCList.txt" Const outFilename = "Online.txt" Const outFileExist2 = "Online.txt" Set WshShell = WScript.CreateObject("WScript.Shell") '------------------------------------------------------------------------------- 'Get current Domain '------------------------------------------------------------------------------- key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon\CachePrimaryDomain" dname = WshShell.RegRead (key) set objEnv = WshShell.Environment("process") dname = objEnv("USERDOMAIN") on error resume next 'Bind to the builtin administrators group to see if you can connect GetObject("WinNT://" & dname &"/administrators") if err.number then message = "Cannot bind to " &dname WshShell.Popup message,0,"Connection or Authority Failure",vbCritical WScript.Quit End If DnameObj = "WinNT://" & dname WshShell.Popup "Please Stand By.....",3,"Query Domain",64 Set objContainer=GetObject(DnameObj) objContainer.Filter=Array("computer") Set fso = CreateObject("scripting.filesystemobject") '------------------------------------------------------------------------------- 'List creation from active directory or User created ? '------------------------------------------------------------------------------- If (MsgBox("Do you want to create a list from active directory ? " &_ "", vbYesNo + vbQuestion,"www.spoogenet.com") = vbYes) Then List Else message = message & "You need to type in you computer names and save file when completed" WshShell.Popup message,0,"www.spoogenet.com",vbInformation WshShell.Run "notepad PCList.txt" End If '------------------------------------------------------------------------------- 'If file exists delete and create from active directory '------------------------------------------------------------------------------- Sub List() If (Not fso.FileExists(outFileExist)) Then isnew = True Else isnew = False End If If isnew = False Then fso.DeleteFile(outFileExist) End If Set outExist = fso.OpenTextFile(outFileExist, ForAppending, True) For Each colPCs in objContainer outExist.writeline colPCs.Name Next If (MsgBox("Done. All PCs in " & dname & " exported to " & outFileExist &_ ". " & vbCrLf & "Open file " & outFileExist & " ?",_ vbYesNo + vbQuestion,"www.spoogenet.com") = vbYes) Then WshShell.Run "notepad PCList.txt" End If If (Not fso.FileExists(outFileExist2)) Then isnew = True Else isnew = False End If If isnew = False Then fso.DeleteFile(outFileExist2) End If Set outExist2 = fso.OpenTextFile(outFileExist, ForAppending, True) For Each colPCs in objContainer outExist.writeline colPCs.Name
|
|
| |
|
|
|
|
|