Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Microsoft Scripting Tools

Status
Not open for further replies.

SQLLady

MIS
Jun 20, 2002
69
US
I am looking for the microsoft scripting tools. Can anyone give me the names of tools that NT Administrators use for
Win2k and others? thanks in advance.
 
aint bad for WHS.

The only problems I have had with WHS is NAV picks up the script as a virus.. DOH 9 but it ant. Here have a nice login on me A and thanks to the writers).
'~~[author]~~
Noel P. Luneau
'~~[/author]~~

'~~[emailAddress]~~
nluneau@psinapse.com
'~~[/emailAddress]~~

'~~[scriptType]~~
vbscript
'~~[/scriptType]~~

'~~[subType]~~
LogonScripts
'~~[/subType]~~

'~~[keywords]~~
logon script, login script, vbscript, kixstart
'~~[/keywords]~~

'~~[comment]~~
Uses IE as a shell to Map Drives, Add Icons, Make Registry changes, etc. No extra Dll's or exe's required. Logs login times and info about user
workstation. Tested with Win2K and XP.

'~~[/comment]~~

'~~[script]~~
File Login.wsf

<?xml version=&quot;1.0&quot; ?>
<job>
<comment>

Title: Login Script v4.0
Date: 5.28.2002
Name: Noel Luneau, MCSE
Email_Address: nluneau@psinapse.com
Script_Type: vbscript
keywords: Logon Script, FileSystemObject, Login, ie
Credits: Chris Kmosko, Microsoft Corporation, Clarence Washington,
David Hamel, Duncan Godwin, Charles, jwarrington*NoSteekinSpam*@att.net

Directions for Win2K/XP
1. Create or use existing Organization Unit (OU) for selected users. 2. Create new or use existing group policy object for selected users. 3. Extract Login.wsf, Log.vbs and legal.txt. 4. Add login.wsf as logon script and copy all extracted file to same directory. 5. Set Your User Defined System Variables below. 6. Add your custom mapping, icon placements and run programs. 7. Test Login.wsf from the \sysvol\domain.com\scripts directory 8. When it works and replication is successful then test via login 9. Have fun cause that's why we're here ... right? riiiiight!

</comment>
<script language=&quot;VBScript&quot;>
<![CDATA[

Option Explicit

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Declarations and Constants '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim bStopClick, bUserClose ' as boolean
Const sCaption = &quot;Login Script&quot; ' titlebar caption
Const READYSTATE_COMPLETE = 4 ' from enum of tagREADYSTATE...

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Instantiate Internet Explorer '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim oIE : Set oIE = WScript.CreateObject(&quot;InternetExplorer.Application&quot;,
&quot;oIE_&quot;)
With oIE : .left = 40 : .top = 80 : .width = 400 : .height = 205
.menubar = False : .toolbar = False : .statusbar = False : End With
oIE.navigate(&quot;about:blank&quot;) ' start with dummy page

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'wait for html page to load...
'while oIE.Busy: WScript.Sleep 100: Wend
'uh-oh, according to mHarris (wshNG), IE sometimes &quot;lies&quot; about being busy, 'and so we'll use ReadyState instead (hopefully readystate doesn't lie). '(If readystate lies too, maybe we could use the &quot;DocumentComplete&quot; event)... '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
While oIE.ReadyState <> READYSTATE_COMPLETE : Wscript.Sleep 100 : Wend

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Load html into the oIE.document '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim oDoc : Set oDoc = oIE.document ' get the document object...

oDoc.Open &quot;text/html&quot; ' open document for writing...
oDoc.Write GetResource(&quot;sDlg_HTML&quot;)
oDoc.Close
while oIE.ReadyState <> READYSTATE_COMPLETE : Wscript.Sleep 100 : wend

' move &quot;Microsoft Internet Explorer&quot; off to the side...
oDoc.Title = sCaption & String(25, Chr(160)) ' note: Chr(160) is the 2nd ansi blank

' finished w/html, show the dialog...
oIE.Visible = True

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'start click wait loop '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
oDoc.all.msgLine1.innertext = &quot; Login script is running... Please wait!
&quot;
WScript.Sleep 250

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'script running (wait for close)
'show some progress messages... '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
oDoc.all.msgLine2.innertext = &quot; The Time is now: &quot; & CStr(Time)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Initialization '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim WshFS
Dim WshF
Dim WshFDC
Dim WshFile
Dim WshFSource
Dim WshAE
Dim WshTSc
Dim WshSW
Dim WshReg
Dim WSHNetwork
Dim WshShell
Dim WshProcessEnvironment
Dim WshLogonServer
Dim strScriptFullName
Dim WshLogonPath
Dim WshInstall
Dim WshCopy
Dim WshSys32
Dim WshSysRoot
Dim EnvWinDir
Dim strSource
Dim strDest
Dim IPAddress
Dim SubnetMask
Dim OS
Dim Username

Set WshFS = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set WSHNetwork = WScript.CreateObject(&quot;WScript.Network&quot;)
Set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
Set WshProcessEnvironment = WshShell.Environment(&quot;Process&quot;)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Set Your User Defined System Variables '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim UseNTServer
'Sets the running of this logon on Windows NT Servers to Yes. To Change it set the value to no UseNTServer = &quot;no&quot; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim DomainName
'Sets the Users Domain
DomainName = &quot;DOMAIN&quot; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Sets the path to the NT Share to write Logs
Const LOGPATH = &quot;\\SERVER\LOGS\&quot; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Sets the path to the NT Share where icons are stored
Const IconSource = &quot;\\SERVER\Copy\&quot; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ShareSvr
'Sets the NT Server that drives are mapped to
ShareSvr=&quot;SERVER&quot; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim LogonSvr
'Sets the NT Server that is the default logon for win9x clients LogonSvr=&quot;SERVER&quot; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim CompanyName
'Sets the Users Company Name
CompanyName = &quot;Company Name&quot; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
oDoc.all.head.innertext = CompanyName

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Determine OS '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
OS = WshProcessEnvironment(&quot;OS&quot;)
If OS <> &quot;Windows_NT&quot; Then
OS = &quot;Win32&quot;
strScriptFullName = Wscript.ScriptFullName
WshLogonServer = mid(strScriptFullName, 1,
instr(3,strScriptFullName,&quot;\&quot;)-1) 'seems to work with and without
the -1
WshSysRoot = WshShell.ExpandEnvironmentStrings(&quot;%SYSTEMROOT%&quot;)
WshLogonPath = WshLogonServer & &quot;\netlogon&quot;
EnvWinDir = WshProcessEnvironment(&quot;windir&quot;)
WshSys32 = EnvWinDir & &quot;\system\&quot;
End If

If UseNTServer = &quot;yes&quot; then
If OS = &quot;Windows_NT&quot; Then
WshLogonServer =
WshShell.ExpandEnvironmentStrings(&quot;%LOGONSERVER%&quot;)
WshSysRoot = WshShell.ExpandEnvironmentStrings(&quot;%SYSTEMROOT%&quot;)
WshLogonPath = WshLogonServer & &quot;\netlogon&quot;
EnvWinDir = WshProcessEnvironment(&quot;windir&quot;)
WshSys32 = EnvWinDir & &quot;\system32\&quot;
End If
Else
If OS = &quot;Windows_NT&quot; Then
IF WshShell.RegRead(&quot;HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType&quot;) = &quot;WinNT&quot; Then
WshLogonServer =WshShell.ExpandEnvironmentStrings(&quot;%LOGONSERVER%&quot;)
WshSysRoot = WshShell.ExpandEnvironmentStrings(&quot;%SYSTEMROOT%&quot;)
WshLogonPath = WshLogonServer & &quot;\netlogon&quot;
EnvWinDir = WshProcessEnvironment(&quot;windir&quot;)
WshSys32 = EnvWinDir & &quot;\system32\&quot;
End If
End If
End If

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Get Username '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Pause Script until User is Logged in
On Error Resume Next
Username = &quot;&quot;
Do
Username = WSHNetwork.UserName
Loop Until Username <> &quot;&quot;

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Init Variables '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Do
strUserID = WSHNetwork.UserName
Loop Until strUserID <> &quot;&quot;

DesktopPath = WSHShell.SpecialFolders(&quot;Desktop&quot;)
ProgramsPath = WSHShell.SpecialFolders(&quot;Programs&quot;)

strPCName = WSHNetwork.ComputerName

'Get User Object
'** Set this for your Domain
Set UserObj = GetObject(&quot;WinNT://&quot; & DomainName & &quot;/&quot; & strUserID)

'Init Groups
Dim UserGroups
Dim GroupObj
UserGroups=&quot;&quot;
For Each GroupObj In UserObj.Groups
UserGroups=UserGroups & &quot;[&quot; & GroupObj.Name & &quot;]&quot;
Next

Dim strUserID 'User Name
Dim strPCName 'PC Name

Dim UserObj 'User NT Object

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''Init Display '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
oDoc.all.msgLine1.innertext = &quot;Welcome User &quot; & strUserID & &quot; on Machine\\&quot; & strPCName

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Display intro '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
oDoc.all.msgLine3.innertext = &quot; ... Now Logging into &quot; & DomainName

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Security Screen
'Legal.txt is the same as the following text '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copy Legal.txt to C:\Legal.txt
' CopyFile WshCopy & &quot;legal.txt&quot;, &quot;c:\legal.txt&quot;

' Legal Text
Text = &quot;This computer is the property of &quot; & CompanyName & &quot;. It is for authorized use only. Users (authorized or unauthorized) have no explicit or implicit expectation of privacy. &quot;
' LoginBox.SetDisplayMessage(Text)
' Text = Text & vbcrlf & &quot;&quot;
' LoginBox.SetDisplayMessage(Text)
' Text = Text & vbcrlf & &quot;Any or all uses of this system and all fileson this system may be intercepted, monitored, recorded, copied, audited, inspected, and disclosed to authorized sites, &quot; & CompanyName & &quot; and law enforcement personnel. By using this system, the user consents to such interception, monitoring, recording, copying, auditing, inspection, and disclosure at the discretion of &quot; & CompanyName & &quot;. &quot;
' LoginBox.SetDisplayMessage(Text)
' Text = Text & vbcrlf & &quot;&quot;
' LoginBox.SetDisplayMessage(Text)
' Text = Text & vbcrlf & &quot;Unauthorized or improper use of this system may result in administrative disciplinary action and civil and criminal penalties. By continuing to use this system you indicate your awareness of and consent to these terms and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the conditions stated in this warning. &quot;
' LoginBox.SetDisplayMessage(Text)
' Text = Text & vbcrlf & &quot;&quot;
' LoginBox.SetDisplayMessage(Text)
' Text = Text & vbcrlf & &quot;To read a copy of this NOTICE please open c:\legal.txt on this system.&quot;
' LoginBox.SetDisplayMessage(Text)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Registry Modifications '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
oDoc.all.msgLine3.innertext = &quot; ... Now Updating Registry &quot;
UpdateRegistry
WScript.Sleep 500

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Drives / Icons / Printers '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
oDoc.all.msgLine3.innertext = &quot; ... Now Adding Drives, Icons and Printers &quot;
ConfigurePC
WScript.Sleep 500

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Run Programs '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Your Program
oDoc.all.msgLine3.innertext = &quot; ... Now Running Programs &quot;
' WshShell.Run &quot;\\SERVER\SHARE\PROGRAM.EXE&quot;, 0, True WScript.Sleep 500

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Set Time '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
oDoc.all.msgLine3.innertext = &quot; ... Now Synching Time &quot;
WshShell.Run &quot;%COMSPEC% /c net time &quot; &WshLogonServer& &quot; /set /y&quot;, 0, FALSE WScript.Sleep 500

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Log Activity '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
oDoc.all.msgLine3.innertext = &quot; ... Now Writing Log File &quot;

If OS = &quot;Win32&quot; Then
If WshFS.FileExists(WshLogonPath & &quot;\log.vbs&quot;) Then
WshShell.Run WshLogonPath & &quot;\log.vbs&quot;, 0, True
End If
Else
If WshFS.FileExists(WshLogonPath & &quot;\log.vbs&quot;) Then
WshShell.Run WshLogonPath & &quot;\log.vbs&quot;, 0, True
End If
End If

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'End Program '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

WScript.Sleep 100
oDoc.all.msgLine3.innertext = &quot;&quot;
' advise user, that we are closing now... oDoc.all.msgLine1.style.color = &quot;RED&quot; ' chanage text color
oDoc.all.msgLine1.innertext = &quot; Script Completed - Closing Now...
&quot;
oDoc.all.msgLine2.innertext = &quot; (window will close in 2 secs)&quot;
WScript.Sleep 2500

oIE.Visible = False ' close internet explorer...
Set oDoc = nothing
Set oIE = nothing
WScript.Quit


'LoginBox.SetWaitMessage(&quot;Read Security Policy and Press Done when complete ... &quot;)
' If UseLogonScreen = &quot;yes&quot; then LoginBox.Pbar(100)
' LoginBox.TimerSet(30) 'This sets the countdown timer value.
' Wscript.quit

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'END OF SCRIPT '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Functions '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Make manual changes to local PC Registry '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub UpdateRegistry

'Clear last user
WSHShell.RegWrite &quot;HKCU\Network\Logon\username&quot;, &quot;&quot;

End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Setup Drives / Icons '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ConfigurePC
On Error Resume Next
' Setup User's Home Directory (U Drive)
WSHNetwork.RemoveNetworkDrive &quot;U:&quot;,&quot;True&quot;
'Wscript.Sleep (5000)
MapDrive &quot;U:&quot;, strUserID & &quot;$&quot;

' COMPANY Wide Documentation Share (G Drive)
WSHNetwork.RemoveNetworkDrive &quot;G:&quot;,&quot;True&quot;
'Wscript.Sleep (5000)
MapDrive &quot;G:&quot;, &quot;Documents$&quot;

' COMPANY Wide Application Share (S Drive)
WSHNetwork.RemoveNetworkDrive &quot;S:&quot;,&quot;True&quot;
'Wscript.Sleep (5000)
MapDrive &quot;S:&quot;, &quot;Shared$&quot;

' DEPARTMENTS

If InGroup(&quot;ACCOUNTING&quot;) Then
ShareSvr = &quot;SERVER&quot;
MapDrive &quot;Q:&quot;, &quot;ACCOUNTING$&quot;
End If

If InGroup(&quot;GROUP2&quot;) Then
ShareSvr = &quot;SERVER&quot;
MapDrive &quot;g:&quot;, &quot;staff\GROUP2&quot;
End If

If InGroup(&quot;GROUP3&quot;) Then
MapDrive &quot;g:&quot;, &quot;staff\GROUP3&quot;
End If

' Applications / Functions

If InGroup(&quot;GROUP1&quot;) Then GROUP1
If InGroup(&quot;GROUP2&quot;) Then GROUP2
If InGroup(&quot;GROUP3&quot;) Then GROUP3

End Sub 'Configure PC

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Setup Printers '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

If InGroup(&quot;PRINTER1&quot;) Then
ShareSvr = &quot;SERVER&quot;
WshNetwork.RemovePrinterConnection &quot;PRINTER1:&quot;,1,1
WshNetwork.AddPrinterConnection &quot;PORT1:&quot;, &quot;PRINTER1&quot;, 1 End If

If InGroup(&quot;PRINTER2&quot;) Then
ShareSvr = &quot;SERVER&quot;
WshNetwork.RemovePrinterConnection &quot;PRINTER2:&quot;,1,1
WshNetwork.AddPrinterConnection &quot;PORT2:&quot;, &quot;PRINTER2&quot;, 1 End If

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub GROUP1
AddIcon &quot;Menu&quot;, &quot;GROUP1.lnk&quot;
AddIcon &quot;DT&quot;, &quot;GROUP1.Lnk&quot;
End Sub

Sub GROUP2
AddIcon &quot;Menu&quot;, &quot;GROUP2.lnk&quot;
AddIcon &quot;DT&quot;, &quot;GROUP2.Lnk&quot;
End Sub

Sub GROUP3
AddIcon &quot;Menu&quot;, &quot;GROUP3.lnk&quot;
AddIcon &quot;DT&quot;, &quot;GROUP3.Lnk&quot;
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Add Icon to User's PC '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub AddIcon (strLocation, Icon)
If strLocation= &quot;DT&quot; Then CopyFile IconSource & Icon, DesktopPath & &quot;\&quot;
If strLocation= &quot;Menu&quot; Then CopyFile IconSource & Icon, ProgramsPath & &quot;\&quot; End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Convert Current Date to FileName '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function DateToStr()
DateToStr = DatePart(&quot;yyyy&quot;,Now()) & DatePart(&quot;m&quot;,Now()) &
DatePart(&quot;d&quot;,Now())
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: MapDrive
' Arguments: Drive Letter (with &quot;:&quot;) and Share Name on ShareSvr ' Description: Maps Share' mapping CANNOT exist already '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub MapDrive( strDrive, strShare )
Dim Path
If InStr(strShare,&quot;\&quot;) then
Path=strShare
Else
Path=&quot;\\&quot; & ShareSvr & &quot;\&quot; & strShare
End If

' Map drive
On Error Resume Next
WSHNetwork.MapNetworkDrive strDrive, Path

' End Sub result
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Return Date of File '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function FileDate(filespec)
Dim fso
Dim f
DateCreated = 0

On Error Resume Next
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set f = fso.GetFile(filespec)

FileDate = f.DateLastModified
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Function: CopyDir
'Parameters:
' strSourceDir - where the files are coming from
' strDestDir - where the files are going
'
' This function copies the contents of one directory to another '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function CopyDir(strSourceDir, strDestDir)
Dim lfsObject
Dim lFileList
Dim lFolder
Dim lFile

Set lfsObject = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set lFolder = lfsObject.GetFolder(strSourceDir)
Set lFileList = lFolder.Files

For Each lFile in lFileList
lfsObject.CopyFile strSourceDir & &quot;\&quot; & lFile.Name, strDestDir & &quot;\&quot; & lFile.Name
Next

Set lfsObject = nothing
Set lFolder = nothing
Set lFileList = nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Function: CopyFile
'Parameters:
' strSourceDir - where the files are coming from
' strDestDir - where the files are going
'
' This function copies the file '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub CopyFile(strSource, strDest)
Dim lfsObject
Dim Source

On Error Resume Next
Set lfsObject = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set Source = lfsObject.GetFile(strSource)

Source.Copy strDest
Set lfsObject = nothing

If Err.Number <> 0 Then WriteErr( strUserID & &quot;: Copy &quot; & strSource & &quot; to &quot; & strDest & &quot; &quot; & Err.Description & &quot; &quot; & Now() ) End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: Make New Directory '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function MD(strDirName)
Dim lFSObj, lFolder

' First See if it already exists
set lFSObj = Wscript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
set lFolder = lFSObj.GetFolder(strDirName)
If Err.number = 0 then
' Yes, it does exist so we don't have to do anything
MD = True
Else
Err.Clear
lFSObj.CreateFolder(strDirName)
If Err.Number <> 0 Then
MD = False
Else
MD = True
End If
End If
Set lFolder = Nothing
Set lFSObj = Nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: Return value of specified environment string
'
' Arguments: Environment variable to find
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetEnv(strName)
Dim strEnv

GetEnv = &quot;&quot;
strName=UCase(strName)
For Each strEnv In WshProcessEnvironment
If strName = UCase(Left(strEnv,Len(strName))) Then
GetEnv=Right(strEnv,Len(strEnv)-Len(strName)-1)
Next
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: Check if user is in Group
'
' Arguments: Group to check membership of
'
' Note: Requires pre-initialization of UserGroups variant '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function InGroup(strGroup)
InGroup=False
If InStr(UserGroups,&quot;[&quot; & strGroup & &quot;]&quot;) Then
InGroup=True
LoginMsg strGroup
End If
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Delete FIle '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub DeleteFile(strFile)
Dim fso
Dim File

On Error Resume Next
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set File = fso.GetFile(strFile)
File.Delete
End Sub


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This function copies the contents of one directory to another '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function CopyFiles(strSourceDir, strDestDir)
On Error Resume Next
Set lfsObject = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set lFolder = lfsObject.GetFolder(strSourceDir)

If strSourceDir > &quot;&quot; then
Set NewFolder = lfsObject.CreateFolder(strDestDir)
' WScript.Echo &quot;Copy Source: &quot; & strSourceDir & &quot; Dest: &quot; & strDestDir

'Process contained files first
Set lFileList = lFolder.Files
For Each lFile in lFileList
lfsObject.CopyFile strSourceDir & &quot;\&quot; & lFile.Name, strDestDir & &quot;\&quot; & lFile.Name
Next

'Process subdirectories
Set lSubFolders = lFolder.SubFolders

For Each lSubFolder in lSubFolders
NewSource = strSourceDir & &quot;\&quot; & lSubFolder.Name
NewDest = strDestDir & &quot;\&quot; & lSubFolder.Name
CopyFiles NewSource, NewDest
Next

End If

Set lfsObject = Nothing
Set lFileList = Nothing
Set lFolder = Nothing
Set lFile = Nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This function deletes all Files specified '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function DelFiles(strSourceDir)
Dim lfsObject
Dim lFileList
Dim lFolder
Dim lFile

On Error Resume Next
Set lfsObject = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set lFolder = lfsObject.GetFolder(strSourceDir)
' WScript.Echo &quot;Delete: &quot; & strSourceDir

'Process contained files first
Set lFileList = lFolder.Files
For Each lFile in lFileList
lFile.Delete
Next

'Process subdirectories
Set lSubFolders = lFolder.SubFolders

For Each lSubFolder in lSubFolders
NewSource = strSourceDir & &quot;\&quot; & lSubFolder.Name

DelFiles NewSource
lSubFolder.Delete
Next

Set lfsObject = Nothing
Set lFileList = Nothing
Set lFolder = Nothing
Set lFile = Nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Determine Drive Size '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function DriveSize (strDrive)
Dim oFileSys, Drive
Set oFileSys = CreateObject(&quot;Scripting.FileSystemObject&quot;)

On Error Resume Next
Set Drive = oFileSys.GetDrive(strDrive)

DriveSize=Int( Drive.TotalSize/(1024^2) )
End Function

Function DriveSizeFree (strDrive)
Dim oFileSys, Drive
Set oFileSys = CreateObject(&quot;Scripting.FileSystemObject&quot;)

On Error Resume Next
Set Drive = oFileSys.GetDrive(strDrive)

DriveSizeFree=Int( Drive.FreeSpace/(1024^2) )
End Function

'''''''''''''''''''''''''''''''''''''''
' Function: Check for existence of file system object
'
' Argument: Name of Object (file or Directory) to check for. '''''''''''''''''''''''''''''''''''''''
Function IfExist(strName)
Dim fso
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
IfExist = False

On Error Resume Next
If fso.FileExists(strName) Then IfExist = True
If fso.FolderExists(strName) Then IfExist = True

Set fso = Nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'END OF FUNCTIONS '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

]]>
</script>

<resource id=&quot;sDlg_HTML&quot;>
<![CDATA[
<html><head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;> <title>Windows Logon Script </title> <style>
BODY { font-family: verdana; font-size: 10pt; font-weight: 600; color: Navy }
BUTTON { font-family: verdana; font-size: 10pt; font-weight: 600; } </style> </head>

<body bgcolor=&quot;Silver&quot; scroll=no >

<center><p ID=&quot;head&quot;> </p></center>

<p ID=&quot;msgLine1&quot;> </p>

<p ID=&quot;msgLine2&quot;> </p>

<p ID=&quot;msgLine3&quot;> </p>

<p ID=&quot;logo&quot; style= &quot; position: absolute; left: 50; top: 155; color: Black; font-family: Arial; font-size: 8pt; font-weight: Normal;
font-style: Italic; &quot; >
Logon Script by PsiNapse Technology Ltd - 877-PSI-TECK</p> </body> </html> ]]> </resource> </job>

--------------------------------------------------------------
File Log.VBS
--------------------------------------------------------------

'Logon Enumerator
'Created 18th Jan 2001
'by Jonathan Chambers
'
'concept by Jonathan Chambers
'comments to jonchambers@hotmail.com

on error resume next

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f

set adsys = CreateObject(&quot;ADSystemInfo&quot;)
set wscr = CreateObject(&quot;WScript.Network&quot;)

Set oDrives = wscr.EnumNetworkDrives
Set oPrinters = wscr.EnumPrinterConnections

'map drive here
wscr.MapNetworkDrive &quot;Y:&quot;, &quot;\\cstvlsql1\logs&quot;

sUserDL = wscr.username
outputfile = &quot;Y:\&quot; & sUserDL & &quot;logon.txt&quot;

Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set f = fso_OpenTextFile(outputfile, ForWriting, True)

sPrefix = &quot;LDAP://&quot;

LogonTime = Time
line = &quot;LogonTime: &quot; & LogonTime
appendit(line)

Logondate = Date
line = &quot;LogonDate: &quot; & LogonDate & chr(13) & chr(10)
appendit(line)

'Get the downlevel logon name of the user

line = &quot;USER DETAILS:&quot; & chr(13) & chr(10) & &quot;sAMAccountname: &quot; & sUserDL
appendit(line)

'Get the Distinguished name of the user
sUserDN = adsys.username
line = &quot;UserDN: &quot; & sUserDN
appendit(line)

'Get the User's telephone extension
Set oUser = Getobject(sPrefix & sUserDN)
sUserExt = oUser.homePhone
line = &quot;Ext: &quot; & sUserExt
appendit(line)

'Get the user's group membership
count = 1
line = &quot;Group Membership:&quot;
appendit(line)
aMems = oUser.GetEx(&quot;memberOf&quot;)
For each mem in aMems
line = count & &quot;) &quot; & mem
appendit(line)
count = count + 1
Next

line = &quot;&quot;
appendit (line)

'Get the short name of the machine
sMach = wscr.computername
line = &quot;PC DETAILS:&quot; & chr(13) & chr(10) & &quot;Computer: &quot; & sMach
appendit(line)

'Get the DN of the machine
sMachDN = adsys.computername
line = &quot;PC_DN: &quot; & sMachDN
appendit(line)

'Get the sitename
sSite = adsys.sitename
line = &quot;Site: &quot; & sSite
appendit(line)

'Get the IP details
set IPConfigSet = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!//localhost&quot;).ExecQuery(&quot;select ServiceName, IPAddress, IPSubnet,DefaultIPGateway, DHCPServer,DHCPLeaseObtained, DNSServerSearchOrder, MACAddress, WINSPrimaryServer,WINSSecondaryServer from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE&quot;)

Count = 0
for each IPConfig in IPConfigSet
Count = Count + 1
next

ReDim sName(Count - 1)
ReDim sIP(Count - 1)
ReDim sDHCP(Count - 1)
ReDim sDNSSO(Count - 1)
ReDim sMAC(Count - 1)
ReDim sWINSP(Count - 1)
ReDim sWINSS(Count - 1)
ReDim sNW(Count - 1)
ReDim sSN(Count - 1)

Count = 0
j = 0

for each IPConfig in IPConfigSet
sName(Count) = IPConfig.ServiceName(0)
line = &quot;Card Name: &quot; & sName(Count)
appendit(line)

sIP(Count) = IPConfig.IPAddress(0)
line = &quot;IP Address: &quot; & sIP(Count)
appendit(line)

sSN(Count) = IPConfig.IPSubnet(0)
line = &quot;Subnet Mask: &quot; & sSN(Count)
appendit(line)

sNW(Count) = IPConfig.DefaultIPGateway(0)
line = &quot;Default Gateway: &quot; & sNW(Count)
appendit(line)

sMAC(Count) = IPConfig.MACAddress(0)
line = &quot;MAC Address: &quot; & sMAC(Count)
appendit(line)

sDHCP(Count) = IPConfig.DHCPServer
line = &quot;DHCP Server: &quot; & sDHCP(Count)
appendit(line)

sWINSP(Count) = IPConfig.WINSPrimaryServer(0)
line = &quot;WINS 1: &quot; & sWINSP(Count)
appendit(line)

sWINSS(Count) = IPConfig.WINSSecondaryServer(0)
line = &quot;WINS 2: &quot; & sWINSS(Count)
appendit(line)

x = 1
if Not IsNull(IPConfig.DNSServerSearchOrder) then
for j=LBound(IPConfig.DNSServerSearchOrder) to UBound(IPConfig.DNSServerSearchOrder)
line = &quot;DNS &quot; & x & &quot;: &quot; & IPConfig.DNSServerSearchOrder(j)
appendit(line)
next
end if

Count = Count + 1
next

line = chr(13) & CHR(10)
appendit(line)

line = &quot;DRIVE MAPPINGS and PRINTERS:&quot;
appendit(line)

'Get the Network Drives mapped
For i = 0 to oDrives.Count - 1 Step 2
line = &quot;Drive &quot; & oDrives.Item(i) & &quot; = &quot; & oDrives.Item(i+1)
appendit(line)
Next

line = chr(13) & CHR(10)
appendit(line)

'Get the Printers connected
For i = 0 to oPrinters.Count - 1 Step 2
line = &quot;Port &quot; & oPrinters.Item(i) & &quot; = &quot; & oPrinters.Item(i+1)
appendit(line)
Next

f.close

wscr.RemoveNetworkDrive &quot;Y:&quot;

'//////////////
Function AppendIt(input)
f.Writeline input
end function

------------------------------------------------------------
File Legal.txt
-----------------------------------------------------------

NOTICE TO USERS

This computer is the property of COMPANY.
It is for authorized use only. Users (authorized or unauthorized) have no explicit or implicit expectation of privacy.

Any or all uses of this system and all files on this system may be intercepted, monitored, recorded, copied, audited, inspected, and disclosed to authorized sites, COMPANY and l aw enforcement personnel. By using this system, the user consents to such interception, monitoring, recording, copying, auditing, inspection, and disclosure at the discretion of COMPANY.

Unauthorized or improper use of this system may result in administrative disciplinary action and civil and criminal penalties. By continuing to use this system you indicate your awareness of and consent to these terms and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the conditions stated in this warning.

'~~[/script]~~
 
thanks for the info. I will start my learning with KIxTART.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top