www.christopherlewis.com
Home
News
Recent Projects
Resume
Code Samples
SMTP SmartHost
SpamAssassin
Wget
Analog Reports
Feedback

If you found any of the tools on this page helpful, any donations would be appreciated.

Ping.cs RemoveURLScan_All.vbs Analog_run.vbs Logon.VBS Analog_Reports.ASP

'----------------------------------------+----------------------------------------
' Login.vbs - Default login script for OU=Local 
'
'  Copyright© 2003, Christopher G. Lewis - HTTP://www.ChristopherLewis.com
'
' Date   Name    Comment
' ------ ------- -----------------------------------------------------------------
' 030507 CGL     Created
'----------------------------------------+----------------------------------------
Option Explicit

Dim objFSO
Dim WshShell
Dim WshNetwork

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell  = WScript.CreateObject ("WSCript.shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")

'Check for CScript
If Not IsCScript() Then
  Wscript.echo WScript.FullName & " must be run with CScript."
  Wscript.Quit 1
End if


Call Main()

'Clean up
Set objFSO = Nothing
Set WshShell  = Nothing
Set WshNetwork = Nothing

'----------------------------------------+----------------------------------------
' Main - Main sub
'
' Date   Name    Comment
' ------ ------- -----------------------------------------------------------------
' 030508 CGL     Created
'----------------------------------------+----------------------------------------
Sub Main()
  Dim bResult

  If MapDrive ("X","\\W2KLewis02\My Music") Then
    Wscript.echo "Mapped drive letter"
  Else
    Wscript.echo "Invalid path or drive letter"
  End if

  WshShell.Run "NET TIME /RTSDOMAIN:LEWIS"

  If Not SetRegKey("HKLM\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\SMBDeviceEnabled",0, "REG_DWORD") THEN
    Wscript.echo "Had problems writing RegKey"
  End if
End Sub

'----------------------------------------+----------------------------------------
' MapDrive - Function to map a drive
'
' Date   Name    Comment
' ------ ------- -----------------------------------------------------------------
' 030508 CGL     Created
'----------------------------------------+----------------------------------------
Function SetRegKey(strKey, strValue, strType)
  WshShell.RegWrite strKey, strValue, strType
  SetRegKey = true
End Function

'----------------------------------------+----------------------------------------
' MapDrive - Function to map a drive
'
' Date   Name    Comment
' ------ ------- -----------------------------------------------------------------
' 030508 CGL     Created
'----------------------------------------+----------------------------------------
Function MapDrive(ByVal strDriveLetter, ByVal strPath)
  Dim objRegExp
  Dim iDrive
  Dim bExists
  Dim colDrives

  Set objRegExp = New RegExp

  strDriveLetter = UCase (strDriveLetter)
  objRegExp.IgnoreCase  = true
  objRegExp.Pattern = "^[F-Z]$"

  If Not objRegExp.Test (strDriveLetter) Then
    MapDrive = False
    Exit Function
  End if

  strDriveLetter = strDriveLetter & ":"

  bExists = False
  Set colDrives = WshNetwork.EnumNetworkDrives()
  For iDrive = 0 To colDrives.Count - 1 Step 2
    If colDrives.Item(iDrive) = strDriveLetter Then
      bExists = True
    End if
  Next

  If bExists Then
    WShNetwork.RemoveNetworkDrive strDriveLetter, true
  End if
  WShNetwork.MapNetworkDrive strDriveLetter, strPath
  WshShell.PopUp "Drive " & strDriveLetter & " connected to " & strPath & " successfully.", 5, "Logon", 0
  MapDrive = True

End Function

'----------------------------------------+----------------------------------------
' IsCscript - Checks CScript vs. WScript
'
' Date   Name    Comment
' ------ ------- -----------------------------------------------------------------
' 020507 CGL     Created
'----------------------------------------+----------------------------------------
Function IsCScript()
  Dim objRegExp
  Set objRegExp = New RegExp
  objRegExp.IgnoreCase  = true
  objRegExp.Pattern = "cscript.exe$"
  IsCScript = objRegExp.Test(WScript.FullName)
  Set objRegExp = Nothing
End Function

'----------------------------------------+----------------------------------------
' End of Logon.vbs
'----------------------------------------+----------------------------------------
Send mail to Webmaster with questions or comments about this web site.
Copyright © 2003-2006 Christopher G. Lewis
Last modified: 12/30/06 by Chris Lewis
Google
speakeasy.net http://www.mersenne.org MCSD

FrontPage