Script To Install Fonts To Workstations

‘ ****************************************************************************

‘ Copy Fonts From Network Share To C:\WINDOWS\FONTS Folder Of Workstation

‘ ****************************************************************************

Set WshShell = CreateObject(“WScript.Shell”)

WshShell.Run “xcopy.exe “”\\%SERVERNAME%\%SHARE \FONTS”” “”C:\windows\fonts”” /C /I /S /E /H /Y /Q”, 1,True

‘ ****************************************************************************

‘ Imports The Registry Information For The New Fonts – Add A New Line For Each New Font

‘ Example : WshShell. RegWrite”HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\%FONT REG KEY%”, “%FONT REG KEY ENTRY%”, “REG_SZ”

‘ ****************************************************************************

Set WshShell = WScript.CreateObject(“WScript.Shell”)

WshShell. RegWrite”HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\Twiggy-Bold (TrueType)”, “Twiggy-Bold.ttf”, “REG_SZ”

WshShell. RegWrite”HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\Twiggy-Light (TrueType)”, “Twiggy-Light.ttf”, “REG_SZ”

email me

Copy Image File Based On Screen Resolution

How to copy image file based on screen resolution.

dim filesys
set filesys=CreateObject(“Scripting.FileSystemObject”)
Set objSh = CreateObject(“Wscript.Shell”)

ScreenRes = funcScreenResolution()
Function funcScreenResolution()
Set objIE = CreateObject(“InternetExplorer.Application”)
objIE.Navigate(“about:blank”)
Do Until objIE.readyState = 4: Loop
width = objIE.document.ParentWindow.screen.width
height = objIE.document.ParentWindow.screen.height
objIE.Quit
funcScreenResolution = array(width,height)
End Function

strResolution = ScreenRes(0) & ” x ” & ScreenRes(1)

Select Case strResolution
Case “800 x 600”
strWallpaperPath = “C:\Temp\Source\800×600.jpg”
Case “1024 x 768”
strWallpaperPath = “C:\Temp\Source\1024×768.jpg”
Case “1152 x 864”
strWallpaperPath = “C:\Temp\Source\1152×864.jpg”
Case “1280 x 768”
strWallpaperPath = “C:\Temp\Source\1280×768.jpg”
Case “1280 x 800”
strWallpaperPath = “C:\Temp\Source\1280×800.jpg”
Case “1280 x 1024”
strWallpaperPath = “C:\Temp\Source\1280×1024.jpg”
Case “1366 x 768”
strWallpaperPath = “C:\Temp\Source\1366×768.jpg”
Case “1440 x 900”
strWallpaperPath = “C:\Temp\Source\1440×900.jpg”
Case “1680 x 1050”
strWallpaperPath = “C:\Temp\Source\1680×1050.jpg”
Case “1920 x 1080”
strWallpaperPath = “C:\Temp\Source\1920×1080.jpg”
Case “1920 x 1440”
strWallpaperPath = “C:\Temp\Source\1920×1440.jpg”
Case Else
End Select

filesys.CopyFile strWallpaperPath, “C:\Temp\Dest”

email me

Add an Active Directory Group to the Local Administrator Group of Workstation(s)

This tutorial will illustrate how to add an Active Directory group to the local administrator group of a workstation(s) using Restricted Groups via Group Policy. This can be useful for temporarily allowing a user or groups of users local administrative access to the workstation if software updates or software installation requires those rights. By adding a AD group to the local workstation administrative group, this allows you to remove users at your own will from that group in Active Directory.

1. Create a new group in Active Driectory

Create a new group in Active Driectory that you wish to add to every workstations local administrator group. DO NOT add any users to this group at this time.

2. Create a new GPO

Create a new group policy object and link it to the desired OU. Make sure that the GPO you are using covers the OU that the WORKSTATIONS you are wanting to give users local administrative rights over.

3. Edit the newly created GPO

Navigate within the newly created GPO to Computer Configuration -> Policies -> Windows Settings -> Security Settings –> Restricted Groups

4. Add your new Active Directory group to the Restricted Group

Right-click the Restricted Groups folder and select “Add Group” to add your new Active Directory group to the Restricted Group. In the Group field, type the name of the newly created Active Directory group and click “OK”

5. Add the Restricted Group to the local administrator group

In the Restricted Group Properties windows click “Add” under the section titled “This group is a member of:” Type “Administrators” (without the quotes and yes it is plural), in the Group Membership window and click “OK”

6. Wait for GPO updates to apply to the workstations

Once your users receive their updated group policy settings every workstation within the OU you specified will have your new Active Directory group as a member of the local administrators group. If you need to force the GPO update on a specific workstation, run “gpupdate /force” in a command window on that workstation.

7. Add a user or group of users to the Active Directory Restricted Group

When you are ready, or in a position where you need to provide local workstation admin rights you can simply add the users or group of users to the Active Directory group that you created for use with Restricted Groups within your Active Directory Management Console.

8. Remove the user or group of users from the AD restriced group

When the user or group of users no longer need the local admin rights simply remove the
user(s) from the Active Directory group and have the user log off or reboot the workstation.

email me

Manage the Volume Dirty Bit

How to manage the volume dirty bit

The FSUtil Dirty command checks or sets the dirty bit for a volume.
The system automatically performs an AutoChk (a boot time ChkDsk
equivalent) whenever it detects the dirty bit during startup. The AutoChk
utility looks for drive errors. You can repair drive errors using the
FSUtil Repair command.

Query Dirty Bit Status

The Query command determines whether the specified volume is dirty
(requires a check). To view the current status of a volume, type FSUtil
Dirty Query C: and press Enter (where C: is the volume you want to
check). The output tells whether or not the specified volume is dirty.

Set the Dirty Bit

The Set command lets you set the dirty bit for the specified volume. You
can use this command when you suspect a volume contains errors and
want to check it during the next boot cycle. To set the dirty bit, type
FSUtil Dirty Query C: and press Enter (where C: is the volume you
want to AutoChk). After you set the dirty bit, you can’t clear it, so setting
the dirty bit always results in a drive check during the next boot cycle.

email me

Find Complex Strings

How to find complex strings on your computer

The Find utility is limited to simple searches where the string is
straightforward. If you want to perform a complex search, you need
the FindStr utility, which can perform standard, case insensitive,
wildcard, and regular expression searches.

For example, to find TXT files that have words that begin with H and
end with o, you can type FindStr “H*o” *.TXT and press Enter. In this
case, the asterisk (*) acts as a wildcard character. Likewise, if you
wanted to find TXT files that contain the words Hello or World (or both),
you can type FindStr “Hello World” *.TXT and press Enter. If the file must
contain both words as a discrete string, then you use the /C command line
switch by typing FindStr /C:”Hello World” *.TXT and pressing Enter.

Regular expressions are an impressive FindStr feature. For example,
if you want to find TXT files that contain Hello at the beginning of
the line and World at the end of the line, you’d type FindStr “^Hello
$World” *.TXT and press Enter.

The caret (^) indicates that Hello must appear at the beginning of the
line and the dollar sign ($) indicates that World must appear at the end
of the line. As with many utilities, type FindStr /? and press Enter to
obtain a full list of features.

email me

Rename Computer Remotely

‘On Error Resume Next

‘open the file system object
Set oFSO = CreateObject(“Scripting.FileSystemObject”)
set WSHShell = wscript.createObject(“wscript.shell”)

Dim sNewCname ‘Variable to hold Computer Name you enter in the inputbox
Dim sOldCname ‘computers current name

‘First param is message text, second is message title
sOldCname = InputBox(“Enter computers current name”,”Computer Rename Utility”)
sNewCname = InputBox(“Enter computers new name”,”Computer Rename Utility”)

Call WSHShell.Run(“cmd.exe /K netdom renamecomputer ” & sOldCname & ” /newname:” & sNewCname & ” /userd:DOMAIN\USER /passwordd:PASSWORD /usero:DOMAIN\USER /passwordo:PASSWORD /force /reboot:5 “)

email me

Disable Unused Network Accounts

email me

Pin and Unpin Applications from the Taskbar and Start Menu

email me

 
function Set-PinnedApplication 
{ 
<#  
.SYNOPSIS  
This function are used to pin and unpin programs from the taskbar and Start-menu in Windows 7 and Windows Server 2008 R2 
.DESCRIPTION  
The function have to parameteres which are mandatory: 
Action: PinToTaskbar, PinToStartMenu, UnPinFromTaskbar, UnPinFromStartMenu 
FilePath: The path to the program to perform the action on 
.EXAMPLE 
Set-PinnedApplication -Action PinToTaskbar -FilePath "C:\WINDOWS\system32\notepad.exe" 
.EXAMPLE 
Set-PinnedApplication -Action UnPinFromTaskbar -FilePath "C:\WINDOWS\system32\notepad.exe" 
.EXAMPLE 
Set-PinnedApplication -Action PinToStartMenu -FilePath "C:\WINDOWS\system32\notepad.exe" 
.EXAMPLE 
Set-PinnedApplication -Action UnPinFromStartMenu -FilePath "C:\WINDOWS\system32\notepad.exe" 
#>  
       [CmdletBinding()] 
       param( 
      [Parameter(Mandatory=$true)][string]$Action,  
      [Parameter(Mandatory=$true)][string]$FilePath 
       ) 
       if(-not (test-path $FilePath)) {  
           throw "FilePath does not exist."   
    } 
    
       function InvokeVerb { 
           param([string]$FilePath,$verb) 
        $verb = $verb.Replace("&","") 
        $path= split-path $FilePath 
        $shell=new-object -com "Shell.Application"  
        $folder=$shell.Namespace($path)    
        $item = $folder.Parsename((split-path $FilePath -leaf)) 
        $itemVerb = $item.Verbs() | ? {$_.Name.Replace("&","") -eq $verb} 
        if($itemVerb -eq $null){ 
            throw "Verb $verb not found."             
        } else { 
            $itemVerb.DoIt() 
        } 
            
       } 
    function GetVerb { 
        param([int]$verbId) 
        try { 
            $t = [type]"CosmosKey.Util.MuiHelper" 
        } catch { 
            $def = [Text.StringBuilder]"" 
            [void]$def.AppendLine('[DllImport("user32.dll")]') 
            [void]$def.AppendLine('public static extern int LoadString(IntPtr h,uint id, System.Text.StringBuilder sb,int maxBuffer);') 
            [void]$def.AppendLine('[DllImport("kernel32.dll")]') 
            [void]$def.AppendLine('public static extern IntPtr LoadLibrary(string s);') 
            add-type -MemberDefinition $def.ToString() -name MuiHelper -namespace CosmosKey.Util             
        } 
        if($global:CosmosKey_Utils_MuiHelper_Shell32 -eq $null){         
            $global:CosmosKey_Utils_MuiHelper_Shell32 = [CosmosKey.Util.MuiHelper]::LoadLibrary("shell32.dll") 
        } 
        $maxVerbLength=255 
        $verbBuilder = new-object Text.StringBuilder "",$maxVerbLength 
        [void][CosmosKey.Util.MuiHelper]::LoadString($CosmosKey_Utils_MuiHelper_Shell32,$verbId,$verbBuilder,$maxVerbLength) 
        return $verbBuilder.ToString() 
    } 
 
    $verbs = @{  
        "PintoStartMenu"=5381 
        "UnpinfromStartMenu"=5382 
        "PintoTaskbar"=5386 
        "UnpinfromTaskbar"=5387 
    } 
        
    if($verbs.$Action -eq $null){ 
           Throw "Action $action not supported`nSupported actions are:`n`tPintoStartMenu`n`tUnpinfromStartMenu`n`tPintoTaskbar`n`tUnpinfromTaskbar" 
    } 
    InvokeVerb -FilePath $FilePath -Verb $(GetVerb -VerbId $verbs.$action) 
} 
 
Export-ModuleMember Set-PinnedApplication

Find Which OU A User Belongs To

email me

Find which OU a user belongs to

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

Set objUser = CreateObject("Wscript.Network")
FindUser = objUser.UserName 'InputBox("Please Enter A UserName", "Find User OU")
If FindUser = "" Then
MsgBox("No UserName Was Added")
WScript.Quit
Else
strUser = FindUser
End If

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
"SELECT distinguishedName FROM 'LDAP://dc=yourdomain,dc=com'WHERE objectCategory='user'AND sAMAccountName='" & strUser & "'"
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName").Value
arrPath = Split(strDN, ",")
intLength = Len(arrPath(1))
intNameLength = intLength - 3
Wscript.Echo "User :" & strUser & vbcrlf & "OU is : " & Right(arrPath(1), intNameLength)
objRecordSet.MoveNext
Loop

Disable/Enable Symantec Protection via Command Line

if “%1” == “stop” (

echo “stopping”

net stop “Symantec Endpoint Protection”

net stop “Symantec Event Manager”

net stop “Symantec Settings Manager”

net stop “Symantec Network Access Control”

“c:\Program Files\Symantec\Symantec Endpoint Protection\smc.exe” -stop

) else (

if “%1” == “start” (

echo “starting”

net start “Symantec Endpoint Protection”

net start “Symantec Event Manager”

net start “Symantec Settings Manager”

net start “Symantec Network Access Control”

“c:\Program Files\Symantec\Symantec Endpoint Protection\smc.exe” -start

) else (
if “%1” == “stop” (

echo “stopping”

net stop “Symantec Endpoint Protection”

net stop “Symantec Event Manager”

net stop “Symantec Settings Manager”

net stop “Symantec Network Access Control”

“c:\Program Files\Symantec\Symantec Endpoint Protection\smc.exe” -stop

) else (

if “%1” == “start” (

echo “starting”

net start “Symantec Endpoint Protection”

net start “Symantec Event Manager”

net start “Symantec Settings Manager”

net start “Symantec Network Access Control”

“c:\Program Files\Symantec\Symantec Endpoint Protection\smc.exe” -start

) else (

if “%1” == “stop_ntp” (

echo “not supported”

)else(

echo “usage: symantic start|stop”

)

)

)

if “%1” == “stop_ntp” (

echo “not supported”

)else(

echo “usage: symantic start|stop”

)

)

)