Wednesday 10 July 2013

VBScrip - List a Perticular Service of All WMI Enabled Computers

On Error Resume Next

InputFile = ("c:\computers.txt")
OutputFile = ("c:\result.txt")
Service = ("netlogon")

Set oFS = CreateObject("Scripting.FileSystemObject")
Set f = oFS.OpenTextFile(InputFile)
Set fr = oFS.CreateTextFile(OutputFile, True)

Computers = f.ReadAll
f.Close
arrComputers = Split(Computers,  vbCrLf)

fr.WriteLine("Server" & vbTab & "Services" & vbTab & "State")

For Each strComputer in arrComputers
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")
    Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")

    For Each objService in colRunningServices 
        If objService.DisplayName = Service Then
            fr.WriteLine(strComputer & vbTab & objService.DisplayName & vbTab & objService.State)
        End If
    Next
Next
MsgBox "Service gathering complete", 0, "Info"

MS Outlook: Working with Safe Mode Command Line Switches

- When something isn’t working right with Outlook we often tell users to start Outlook in safe mode or using the /safe switch. This loads Outlook without many of the customization files and add-ins loaded. If outlook works correctly in Safe mode, the problem is with one of add-ins or customization files.

We can use one of these methods to start Outlook using a command line switch:

    Hold Ctrl key as we click the Outlook shortcut.
    If Run…. is shown on start menu (any version of Windows) click it and type outlook.exe /safe in the Open field and click OK.

- In most cases we only need to type outlook or outlook.exe, but occasionally Windows complains that it can’t find the file. When this happens we need to use the full path to Outlook.

- The default location is usually C:\Program Files\Microsoft Office\OfficeXX, where XX is our version number. We can browse to it or look on the Quick Launch shortcut for the file path. Do this by right click on the Outlook shortcut on Quick Launch toolbar and choosing Properties. The default switch is /recycle, we can replace this with /safe, press Apply then double-click on the shortcut to run it (leave the dialog open). After Outlook opens, replace safe with recycle and click OK.

- In most cases we only need to type outlook or outlook.exe, but occasionally Windows complains that it can’t find the file. When this happens we need to use the full path to Outlook.

- The default location is usually C:\Program Files\Microsoft Office\OfficeXX, where XX is our version number. We can browse to it or look on the Quick Launch shortcut for the file path. Do this by right click on the Outlook shortcut on Quick Launch toolbar and choosing Properties. The default switch is /recycle, we can replace this with /safe, press Apply then double-click on the shortcut to run it (leave the dialog open). After Outlook opens, replace safe with recycle and click OK

- If Outlook is not closing properly, look in Task Manager, Processes tab and verify it’s not running. We can open Task Manager by right clicking on the Windows task bar and choosing Task Manager.

The following safe switches are available:

/safe 

Starts Outlook without extensions, Reading Pane, or toolbar customization. Works with all versions.

/safe:1 

Starts Outlook with the Reading Pane off. Outlook 2003/2007 only.

/safe:2 

Starts Outlook without checking mail at startup. Outlook 2003/2007 only.

/safe:3 

Starts Outlook with extensions turned off, but listed in the Add-In Manager. Outlook 2003/2007.

/safe:4

Starts Outlook without loading Outcmd.dat (customized toolbars) and *.fav file. Outlook 2003/2007.

Thank You


Batch File: List a Perticular Service of All WMI Enabled Computers

@echo off
for /F %%s in (d:\Servers.txt) do (
  echo Processing %%s
  echo Processing %%s >> d:\Services.txt
  sc.exe \\%%s query netlogon >> d:\Services.txt
  echo. >> d:\Services.txt
)