Mis Tools

To run CMD by local SYSTEM account 


On Vista or Windows 7 systems:
1. Run CMD as administrator and then type in the followling command lines:
sc create testsvc binpath= "cmd /K start" type= own type= interact
sc start testsvc
2. You will get a popup window from "Interactive Services Detection". Click View the message. Then you will receive a cmd prompt running by SYSTEM.
On Windows Server 2008 you can use PSexec tool
psexec -i -s cmd.exe
 This is useful to troubleshoot some connectivity issue in SCCM environments.
 
For XP and WS 2003
 
sc create CmdAsSystem type= own type= interact binPath= "cmd /c start cmd /k (cd c:\ ^& color ec ^& title ***** SYSTEM *****)"
net start CmdAsSystem
rem sc delete CmdAsSystem

 

Return the platform architecture sub

'--------------------------------------
' by Neven Radic, www.ntcenter.ca
' return the platform architecture
' Jan-12-2010
'-------------------------------------
GETOSARC
Sub GETOSARC 'return sARC = X64|X86
Dim objWMIService
Dim colSettings
Dim objOS
Dim strComputer
 strComputer = "."
 Set objWMIService = GetObject("winmgmts:" _
  & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" & strComputer & "\root\cimv2")
 Set colSettings = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
 For Each objOS In colSettings
  'Wscript.Echo "Name: " & objOS.Name
  Wscript.Echo "OSArchitecture: " & objOS.OSArchitecture
 If InStr(objOS.OSArchitecture,"86")Then
  sARC = "X86"
 ElseIf InStr(objOS.OSArchitecture,"64") Then
  sARC = "X64"
 End If
Next
End Sub
 

Scan SCCM or SMS 2003 client's log for errors

Or if you want to filter logs by name, search for other key words except 'error' or specified your path to log folder (other then SCCM\LOGS) download updated script here.

'-------------------------------------------------------------
' by Neven Radic, Feb-09-2010
' Purpose:  Scan SMS or SCCM clients for errors in the LOGs folder
' Usage:    cscript scanlogs.vbs <Scan Mode>
' "Scan Modes: 0=All | 1=Current | 2=Historical | 3=LO_ | 4=Core | 5=WUA"
' Copyright (C) 2010 NT Consulting Inc.
' Script Version:     1.1.0
' History:  02/5/2010  Created initial version.
'-------------------------------------------------------------
'-------------------------------------------------------------
 
Dim logfile, sPath, precessMODE, p, e, t, sClientPath, sRegKeyPath
Set fso = CreateObject("Scripting.FileSystemObject")
Call GetCMClientPath ' 'return sClientPath value if SCCM Client present
If sClientPath = "" Then
sRegKeyPath = "HKLM\SOFTWARE\Microsoft\SMS\Client\Configuration\Client Properties\Local SMS Path"
Call GetRegValue(sRegKeyPath) ' get SMS 2003 client path, returns: sRegKey
End If
sPath = sClientPath & "Logs\"
Set objArgs = WScript.Arguments
If objArgs.Count = 0 Then
precessMODE = 4
Else
precessMODE = objArgs(0)
End If

Call ListFilesInFolder(sPath)
WScript.Echo " ================== END of SCAN ================="
WScript.Echo "Scan Modes: 0=All | 1=Current | 2=Historical | 3=LO_ | 4=Core | 5=WUA"
WScript.Echo "Total Log files found: "  & t & " -- scan mode: " & precessMODE
WScript.Echo "Total log files processed: " & p & " <---> error(s) found: " & e 
'------------------- SUBs & Funtions ------------------------
'============================================================
Sub ListFilesInFolder(sFolder)
On Error Resume Next
Dim folder, files, NewsFile
If sFolder = "" Then
     Wscript.Echo "No Folder parameter was passed"
     WScript.Quit
End If 
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files
i = 0 : e = 0 : p = 0 : t = 0
For Each file In files
  t = t + 1
   logfile = sPath & file.Name
  
If precessMODE = 0 Then ' process all
   If Ucase(Right(file.name, 4)) = ".LOG" Or Ucase(Right(file.name, 4)) = ".LO_" Then ' process All
       WScript.Echo "Processing: " & file.Name
       p = p + 1
    Call CheckLog(logfile)
  End If
ElseIf precessMODE = 1 Then
        If Ucase(Right(file.Name, 4)) = ".LOG" Then ' process Current Log
      If InStr(file.Name,"-") = 0 Then ' Exclude historical logs
       WScript.Echo "Processing: " & file.Name
       p = p + 1
    Call CheckLog(logfile)
     End If
  End If
ElseIf precessMODE = 2 Then ' process historical '-'
   If Ucase(Right(file.name, 4)) = ".LOG" Then ' process Current Log
      If InStr(file.Name,"-") > 0 Then ' Include historical logs
       WScript.Echo "Processing: " & file.Name
       p = p + 1
    Call CheckLog(logfile)
     End If
  End If
ElseIf precessMODE = 3 Then ' process LO_
  If Ucase(Right(file.name, 4)) = ".LO_" Then
        WScript.Echo "Processing 'LO_' logs: " & file.Name
        p = p + 1
     Call CheckLog(logfile)
  End If
ElseIf precessMODE = 4 Then
        If Ucase(Right(file.Name, 4)) = ".LOG" Then ' process Current Log
      If InStr(file.Name,"-") = 0 Then ' Exclude historical logs
         If InStr(UCase(file.Name),"CCMEXEC") <> 0 Then
         WScript.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"CAS") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"CLIENTAUTH") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"CLIENTLOCATION") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"DATATRANSFERSERVICE") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"POLICYEVALUATOR") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"POLICYAGENT") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    End  If
   End If
  End If
ElseIf precessMODE = 5 Then
        If Ucase(Right(file.Name, 4)) = ".LOG" Then ' process Current Log
      If InStr(file.Name,"-") = 0 Then ' Exclude historical logs
      
       If InStr(UCase(file.Name),"WUAHANDLER") <> 0 Then
         WScript.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"SCANAGENT") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"PATCHINSTALL") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"UPDATESDEPLOYMENT") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    ElseIf InStr(UCase(file.Name),"UPDATESHANDLER") <> 0 Then
     Script.Echo "Processing: " & file.Name
         p = p + 1
      Call CheckLog(logfile)
    End  If
   End If
  End If
 End If
Next
'WScript.Echo "Total Log files found: "  & t
End Sub
'----------------------------------------------
Sub CheckLog(logfile)
contents = fso.OpenTextFile(logfile).readall
lines = split( contents, vbCRLF )
linecount = ubound(lines)
for i = 0 to linecount
 'if instr(1, ucase( lines(i) ), "ERROR") Or instr(1, ucase( lines(i) ), "FAILED") Then
 if instr(1, ucase( lines(i) ), "ERROR") Then
 WScript.echo "error found in " & logfile & " at line " & i & ": " & lines(i)
 e = e + 1
 End If
Next
End Sub
'----------------------------------------------
Function GetCMClientPath 'return sClientPath value
' by Neven Radic
' return sClientPath value

Dim wshShell: Set wshShell = CreateObject("Wscript.Shell")
Dim sClientPath: sClientPath = WshShell.ExpandEnvironmentStrings("%UATDATA%")
 If InStr(sClientPath,"CCM") <> 0 Then ' CM Client path exist
  sClientPathArr = Split(sClientPath,"\UATData\")
  sClientPath = sClientPathArr(0) & "LOGS\"
  WScript.Echo "CM Client path = " & sClientPath
 Else
  WScript.Echo "CM Client can't be found."
 End If
End Function
'----------------------------------------------
Sub GetRegValue(sRegPath) 'return: sRegKey
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
sClientPath = WshShell.RegRead(sRegPath)
WScript.Echo sClientPath
End Sub
----------------------------------------------

How to check Key management services (KMS)  for Windows Registration

 
nslookup -type=all _vlmcs._tcp>kms.txt
 
and here is good MS artical :