Skip to content


Script for GPO to change SCCM client site ID

Option Explicit

Dim objSMSClient
Dim varSiteID

varSiteID = Wscript.Arguments.Named("SiteID")

If Trim(varSiteID) <> "" Then
 Set objSMSClient = CreateObject("Microsoft.SMS.Client")
 objSMSClient.SetAssignedSite(varSiteID)
End If

Posted in Scripts.

Tagged with , , , .


Excel Macro to Convert to CamelHumpNotation

This is a macro that convert values to CamelHumpNotation
Sub FixCamelHump()
'
' FixCamelHump Macro
'
    Dim strValue As String

    Range("A1").Select
    strValue = ActiveCell.Value
    Do While strValue <> ""
        ActiveCell.Value = FixThisString(strValue)
        ActiveCell.Offset(1, 0).Select
        strValue = ActiveCell.Value
    Loop
End Sub

Private Function FixThisString(strValue As String)
    Dim intCnt As Integer
    Dim blnStartOfWord As Boolean
    Dim strBuild As String
    Dim strCurrentChar As String

    For intCnt = 1 To Len(strValue)
        strCurrentChar = Mid(strValue, intCnt, 1)
        If IsLetter(strCurrentChar) = True Then
            If blnStartOfWord = False Then
                blnStartOfWord = True
                strBuild = strBuild & UCase(strCurrentChar)
            Else
                strBuild = strBuild & LCase(strCurrentChar)
            End If
        Else
            If blnStartOfWord = True Then
                blnStartOfWord = False
            End If
            strBuild = strBuild & strCurrentChar
        End If
    Next
    FixThisString = strBuild
End Function

Private Function IsLetter(strChar As String) As Boolean
    If Asc(strChar) >= 97 And Asc(strChar) <= 122 Or Asc(strChar) >= 65 And Asc(strChar) <= 90 Then
        IsLetter = True
        Exit Function
    End If
    IsLetter = False
End Function

Posted in Scripts.

Tagged with , , .


Generic InputBox for CMDs

Usage: CScript.exe //NOLOGO InputBox.vbs /SendTo:SOMEAPP.BAT /prompt:”YOUR PROMPT GOES HERE” /title:”YOUR TITLE GOES HERE”

Example: CScript.exe //NOLOGO InputBox.vbs /SendTo:RUN.BAT /prompt:”Please enter you name” /title:”Name?”

Value supplied will be send to RUN.BAT as %1

Download InputBox.vbs -> http://cr.tl/11ty

Posted in Scripts.

Tagged with , , .


VBS implementation of REG.exe for use in GPOs

Usage: REG.vbs /Action:ADD|/Action:DELETE /Key:REGISTRYKEY [/Value:REGISTRYVALUE] [/DATA:REGISTRYVALUEDATA] [/TYPE:REGISTRYVALUETYPE]

Examples:

REG.vbs /Action:Add /Key:HKLM\SOFTWARE\NewKey


REG.vbs /Action:Add /Key:HKLM\SOFTWARE\NewKey /Value:New_REG_SZ /Data:Value /Type:REG_SZ


REG.vbs /Action:Add /Key:HKLM\SOFTWARE\NewKey /Value:New_REG_Binary /Data:”0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0″ /Type:REG_BINARY


REG.vbs /Action:Add /Key:HKLM\SOFTWARE\NewKey /Value:New_REG_DWORD /Data:0 /Type:REG_DWORD


REG.vbs /Action:Add /Key:HKLM\SOFTWARE\NewKey /Value:New_REG_EXPAND_SZ /Data:Value /Type:REG_EXPAND_SZ


REG.vbs /Action:Add /Key:HKLM\SOFTWARE\NewKey /Value:New_REG_MULTI_SZ /Data:”Value1,Value2,Value3″ /Type:REG_MULTI_SZ


REG.vbs /Action:Delete /Key:HKLM\SOFTWARE\NewKey /Value:New_REG_SZ


REG.vbs /Action:Delete /Key:HKLM\SOFTWARE\NewKey


http://cr.tl/11iy


Posted in Scripts.

Tagged with , , , .


How to start a disk cleanup on remote computer

If you want to start a disk cleanup with cleanmgr.exe, a sageset needs to exist.
Then following batch first replicates the settings that the command “cleanmgr /sageset:777” with all options selected would have create. After that it executes “cleanmgr /sagerun:777”.
For more info on cleanmgr.exe see http://cr.tl/11hm


@Echo Off
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Compress old files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Content Indexer Cleaner” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Microsoft_Event_Reporting_2.0_Temp_Files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Remote Desktop Cache Files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\WebClient and WebPublisher Cache” /v “StateFlags0777″ /t REG_DWORD /d 00000002 /f
CleanMgr /sagerun:777


This batch file can then be executed on remote host with PSExec from Sysinternals
PSExec.exe \\RemoteHost -c -d -f DiskCleanup.bat

Posted in Scripts.

Tagged with , .