Check Network Connectivity – Simple

on error resume next
strURL = “www.google.com”
ConnectionTest = WSHShell.Run(“cmd /c ping -n 2 ” & strURL, 0, True)
‘If ConnectionTest = 0 then msgbox “You are connected!”
If ConnectionTest = 1 then
msgbox “This computer is not connected to the network. Please check your connection and try again.”
””location.reload()’used for HTAs
end if

email me

Determine Network Connectivity

Set WshShell = CreateObject(“WScript.Shell”)
Set objExecObject = WshShell.Exec (“ping -n 3 -w 1000 www.google.com”)

‘ Error Running Ping
If objExecObject.ExitCode <> 0 Then
IsAlive = “UnResolved”
Else
‘ Check if Computer is Alive
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
If Instr(strText, “Reply”) > 0 Then
IsAlive = “Alive”
msgbox “Alive”
Else
IsAlive = “Dead”
msgbox “Dead”
End If
Loop
End If

email me

Copy Files to Remote Machines via Server List

@Echo off
Title Administrative Copy Engine
color 0a
Setlocal EnableDelayedExpansion

REM EXTERNAL VARIABLES
rem Server file(s) path
set Server=I:\temp\_Script_engine

rem Report name
Set report=Report.txt

rem Enter name of computer text file
Set PCList=server_list.txt

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file01=testfile.txt
Set path01=Users\%username%\Desktop

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file02=none
Set path02=none

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file03=none
Set path03=none

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file04=none
Set path04=none

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file05=none
Set path05=none

REM INTERNAL VARIABLES – do not edit below this line
rem —————————————————————————-

REM CREATES DATE AND TIME TIMESTAMP
for /F “tokens=2-4 delims=/- ” %%p in (‘date/T’) do set mdate=%%r%%p%%q
for /F “tokens=1-2 delims=:- ” %%p in (‘time/T’) do set mtime=%%p%%q

Set ReportN=%mdate%_%mtime%_%report%

cls
Echo Report name: %ReportN%
echo.
echo File Name 1: %file01%
echo Copy Path 1: %path01% && echo.

if %file02% NEQ none echo File Name 2: %file02%
if %file02% NEQ none echo Copy Path 2: %path02% && echo.

if %file03% NEQ none echo File Name 3: %file03%
if %file03% NEQ none echo Copy Path 3: %path03% && echo.

if %file04% NEQ none echo File Name 4: %file04%
if %file04% NEQ none echo Copy Path 4: %path04% && echo.

if %file05% NEQ none echo File Name 5: %file05%
if %file05% NEQ none echo Copy Path 5: %path05% && echo.

Echo The script engine reports these as your current settings
echo.

@rem gurantees you start in the right folder
cd\
cd %server%
pause

cls

REM PROGRAM ROUTINE
:CYCLE
for /f “tokens=* delims= ” %%a in (%PCList%) do (
echo Loading workstation name…
ping %%a | find “Reply” > nul
if errorlevel 1 (echo !date! !time! %%a, OFFLINE >> “%ReportN%”
echo %%a not found…
echo %%a>> “offline_machines.txt”
echo.
echo.
%windir%\system32\ping.exe -n 2 127.0.0.1>nul
) else (
echo !date! !time! %%a, ONLINE >> “%ReportN%”
echo Found %%a…
%windir%\system32\ping.exe -n 2 127.0.0.1>nul

echo Copying File 1: %file01% to %path01%…
%windir%\system32\ping.exe -n 2 127.0.0.1>nul
copy /y /v “%server%\files\%file01%” “\\%%a\c$\%path01%\”

if %file02% NEQ none echo Copying File 2: %file02% to %path02%…
if %file02% NEQ none %windir%\system32\ping.exe -n 2 127.0.0.1>nul
if %file02% NEQ none copy /y /v “%server%\files\%file02%” “\\%%a\c$\%path02%\”

if %file03% NEQ none echo Copying File 3: %file03% to %path03%…
if %file03% NEQ none %windir%\system32\ping.exe -n 2 127.0.0.1>nul
if %file03% NEQ none copy /y /v “%server%\files\%file03%” “\\%%a\c$\%path03%\”

if %file04% NEQ none echo Copying File 4: %file04% to %path04%…
if %file04% NEQ none %windir%\system32\ping.exe -n 2 127.0.0.1>nul
if %file04% NEQ none copy /y /v “%server%\files\%file04%” “\\%%a\c$\%path04%\”

if %file05% NEQ none echo Copying File 5: %file05% to %path05%…
if %file05% NEQ none %windir%\system32\ping.exe -n 2 127.0.0.1>nul
if %file05% NEQ none copy /y /v “%server%\files\%file05%” “\\%%a\c$\%path05%\”

echo Copy to %%a is complete.

rem CAN BE REMOVED TO SPEED UP COPYING
%windir%\system32\ping.exe -n 2 127.0.0.1>nul
echo.
echo.
)
)
pause
endlocal
exit /b 0

email me

VBScript – BitLocker Compliance Script

cif = “”

Set s = CreateObject(“WScript.Shell”)
Set e = s.Exec(“manage-bde -status”)
Set status = e.StdOut

Do While status.AtEndOfStream <> True
line = status.ReadLine
If InStr(line, “Volume “) Then
cif = cif & Mid(line, 8, 2)
ElseIf InStr(line, “Conversion Status:”) Then
cif = cif & Mid(line, 26)
ElseIf InStr(line, “Percentage Encrypted:”) Then
cif = cif & “,” & Mid(line, 26) & “; ”
End If
Loop

WScript.Echo cif

email me

Clear Multiple DNS Servers’ Caches

Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objTS = objFSO.OpenTextFile(“c:\dnsservers.txt”)
Do Until objTS.AtEndOfStream
strComputer = objTS.ReadLine
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” & strComputer & _
“\root\MicrosoftDNS”)
Set colItems = objWMIService.ExecQuery( _
“Select * From MicrosoftDNS_Cache”)
For Each objItem in colItems
objItem.ClearCache()
Next
Loop
objTS.Close

email me

Get Ping Information

strComputer = “www.eddiejackson.net”
Set cPingResults = _
GetObject(“winmgmts://./root/cimv2”).ExecQuery(“SELECT * ” & _
“FROM Win32_PingStatus WHERE Address = ‘” & strComputer & “‘”)
For Each oPingResult In cPingResults
If oPingResult.StatusCode = 0 Then
WScript.Echo strComputer & ” Responds from ”
WScript.Echo oPingResult.ProtocolAddress
WScript.Echo “Response time ” & oPingResult.ResponseTime
WScript.Echo “Source routes ” & oPingResult.SourceRoute
Else
WScript.Echo strComputer & ” Doesn’t respond”
End If
Next

email me

Read Names From File

‘Create a FileSystemObject
Set oFS = _
CreateObject(“Scripting.FileSystemObject”)
‘Open a text file of computer names
‘with one computer name per line
Set oTS = oFS.OpenTextFile(“c:\computers.txt”)
Set oTSOut = oFS.CreateTextFile(“c:\errors.txt”)
‘go through the text file
Do Until oTS.AtEndOfStream
‘get next computer
sComputer = oTS.ReadLine
On Error Resume Next
‘***MAKE CONNECTION***
If Err <> 0 Then
oTSOut.WriteLine “Error on ” & sComputer & _
“:” & Err.Number & “, ” & Err.Description
Else
On Error Goto 0
‘***REST OF CODE HERE
End If
Loop
oTS.Close
oTSOut.Close

email me

Event Log Scanner

strComputer = “.”
Set SWBemlocator = CreateObject(“WbemScripting.SWbemLocator”)
Set objWMIService = SWBemlocator.ConnectServer(strComputer, _
“\root\CIMV2”,UserName,Password)
Set colItems = _
objWMIService.ExecQuery(“Select * from Win32_NTLogEvent”)
For Each objItem in colItems
If objItem.EventIdentifier = 1073741925 Then
WScript.Echo “TimeGenerated: ” & objItem.TimeGenerated
WScript.Echo “TimeWritten: ” & objItem.TimeWritten
WScript.Echo “User: ” & objItem.User
End If
Next

email me

Clear temp and iPhone Stuff

This script was set as a logoff script for all domain users via GP.

@ECHO off
DEL /F /S /Q %TEMP%

DEL /F /S /Q “%APPDATA%\Apple Computer\iTunes\iPhone Software Updates\*.ipsw”
DEL /F /S /Q “%APPDATA%\Apple Computer\iTunes\iPhone Software Updates\*.ipsw.signature”
RMDIR /S /Q “%APPDATA%\Apple Computer\MobileSync\Backup”
MKDIR “%APPDATA%\Apple Computer\MobileSync\Backup”

email me

Record Logoff

On Error Resume Next

Dim WshShell, WshNetwork,PC,UN,rs,conn
Set conn = CreateObject(“ADODB.Connection”)
Set rs = CreateObject(“ADODB.RecordSet”)
Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set WshNetwork = WScript.CreateObject(“WScript.Network”)

PC = ucase(WshNetwork.ComputerName)
UN = WshNetwork.UserName

conn.Open “Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\SERVERNAME\RMDelivery\LogonRecords.mdb;”
strSQL = “Update machlogon Set logoffDateTime='” & Now() & “‘ WHERE ((UID='” & lcase(UN) & “‘) AND (machID='” & ucase(PC) & “‘) AND (logoffDateTime IS NULL))”
conn.execute strSQL

Set conn=nothing
Set rs = Nothing
set WshShell=nothing
set WshNetwork=nothing

File: http://eddiejackson.net/data/LogonRecords.mdb

email me

Record Logon

On Error Resume Next

Dim WshShell, WshNetwork,PC,UN,rs,conn,strbookmark,strID
Set conn = CreateObject(“ADODB.Connection”)
set rs = CreateObject(“ADODB.RecordSet”)
Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set WshNetwork = WScript.CreateObject(“WScript.Network”)

PC = ucase(WshNetwork.ComputerName)
UN = WshNetwork.UserName

conn.Open “Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\SERVERNAME\RMDelivery\LogonRecords.mdb;”

PC = ucase(WshNetwork.ComputerName)
UN = WshNetwork.UserName

rs.open “machlogon”,conn,3,3
rs.addnew
rs(“UID”) = lcase(UN)
rs(“machID”) = ucase(PC)
rs(“logonDateTime”) = Now()
rs(“logoffDateTime”) = Null
rs.update
strbookmark = rs.AbsolutePosition
rs.Requery
rs.AbsolutePosition = strbookmark
strID = rs(“logonID”)
rs.close

‘Write an ID number to a file for use when they logoff
dim fs,f
strID= Null
set f=nothing
set fs=nothing
Set conn=nothing
set rs=nothing
set WshShell=nothing
set WshNetwork=nothing

File: http://eddiejackson.net/data/LogonRecords.mdb

email me

TightVNC MSI Install Via .bat

@echo off
echo.
echo Install TightVNC
echo.
echo.
echo INSTALLING AND CONFIGURING
msiexec /i M:\Software\tightvnc-2.7.7-setup-32bit.msi /quiet /norestart ADDLOCAL=”Server,Viewer” VIEWER_ASSOCIATE_VNC_EXTENSION=1 SERVER_REGISTER_AS_SERVICE=1 SERVER_ADD_FIREWALL_EXCEPTION=1 VIEWER_ADD_FIREWALL_EXCEPTION=1 SERVER_ALLOW_SAS=1 SET_USEVNCAUTHENTICATION=1 VALUE_OF_USEVNCAUTHENTICATION=1 SET_PASSWORD=1 VALUE_OF_PASSWORD=c0nn3cT. SET_USECONTROLAUTHENTICATION=1 VALUE_OF_USECONTROLAUTHENTICATION=1 SET_CONTROLPASSWORD=1 VALUE_OF_CONTROLPASSWORD=C0nTr0l
echo.
echo.
echo FINISHED

pause

email me