To run CMD by local SYSTEM accountOn 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 testsvcOn 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 CmdAsSystemrem sc delete CmdAsSystemReturn the platform architecture sub'--------------------------------------
' by Neven Radic, www.ntcenter.ca' return the platform architecture' Jan-12-2010'-------------------------------------GETOSARCSub GETOSARC 'return sARC = X64|X86Dim objWMIServiceDim colSettingsDim objOSDim 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 IfNextEnd SubScan SCCM or SMS 2003 client's log for errorsOr 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, sRegKeyPathSet fso = CreateObject("Scripting.FileSystemObject")Call GetCMClientPath ' 'return sClientPath value if SCCM Client presentIf sClientPath = "" Then sRegKeyPath = "HKLM\SOFTWARE\Microsoft\SMS\Client\Configuration\Client Properties\Local SMS Path"Call GetRegValue(sRegKeyPath) ' get SMS 2003 client path, returns: sRegKeyEnd IfsPath = sClientPath & "Logs\"Set objArgs = WScript.ArgumentsIf objArgs.Count = 0 Then precessMODE = 4 ElseprecessMODE = objArgs(0)End IfCall 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: " & precessMODEWScript.Echo "Total log files processed: " & p & " <---> error(s) found: " & e '------------------- SUBs & Funtions ------------------------'============================================================Sub ListFilesInFolder(sFolder)On Error Resume NextDim folder, files, NewsFileIf sFolder = "" Then Wscript.Echo "No Folder parameter was passed" WScript.QuitEnd If Set folder = fso.GetFolder(sFolder)Set files = folder.Filesi = 0 : e = 0 : p = 0 : t = 0For 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 IfElseIf 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 IfElseIf 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 IfElseIf 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 IfElseIf 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 IfElseIf 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 IfNext'WScript.Echo "Total Log files found: " & tEnd Sub'----------------------------------------------Sub CheckLog(logfile)contents = fso.OpenTextFile(logfile).readalllines = 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 IfNextEnd Sub'----------------------------------------------Function GetCMClientPath 'return sClientPath value' by Neven RadicDim 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 IfEnd Function'----------------------------------------------Sub GetRegValue(sRegPath) 'return: sRegKeyDim WshShellSet WshShell = WScript.CreateObject("WScript.Shell")sClientPath = WshShell.RegRead(sRegPath)WScript.Echo sClientPathEnd Sub----------------------------------------------How to check Key management services (KMS) for Windows Registrationnslookup -type=all _vlmcs._tcp>kms.txtand here is good MS artical :
|