Pages

Friday 20 July 2012

Get all services which are running - PowerShell Command


Get-Service | Where {$_.Status -eq "running"}

What are Cmdlets

Cmdlets are specialized commands in the PowerShell environment that implement specific functions. These are the native commands in the PowerShell stack. Cmdlets follow a <verb>-<noun> naming pattern, such as Get-ChildItem

Display Message with Timer - VBScript



Following Script displays a message for 60seconds OR until user clicks OK.

a = "WSS 4.1 is already installed, Exiting WSS 5.0 Installation"
Set sh = CreateObject("WScript.Shell")
sh.Popup a,60, ""


Wednesday 18 July 2012

Check if Registry Exists - VBScript


Const HKEY_CURRENT_USER = &H80000002


strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")


strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{039694F1-2108-4B3E-8575-85C245210F94}"


strValueName = "DisplayName"
objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,StrValue




If IsNull(StrValue) Then
    Wscript.Echo "The registry key does not exist."
Else
    Wscript.Echo "The registry key exists."
End If

Bring a Process to Front for User Focus - AutoIT Script


Compile the following script using AutoIT and pass the process to be brought to front as commandline


For Example: BringToFront.exe "Caculator"





 AutoIt Version: 3.3.0.0
 Author:         myName


 Script Function:
Bring Window to front.


#ce ----------------------------------------------------------------------------
AutoItSetOption("TrayIconHide", 1)


If $CmdLine[0] > 0 Then
$WinTitle = $CmdLIne[1]
Else
Exit 1
EndIf
If $CmdLine[0] > 1 Then
$WinText = $CmdLIne[2]
Else
$WinText = ""
EndIf


WinWait($WinTitle, $WinText, 60)
If WinExists($WinTitle, $WinText) Then
WinActivate($WinTitle, $WinText)
EndIf


Remove Trailing Backslash - VBScript




On Error Resume Next


Dim strNewValue, Path, slash


       Path = InputBox("Enter Folder Path", "Please Enter", "")


       slash = Len(DatabasePath1)-1


       strNewValue = mid(Path, 1, slash)


msgbox StrNewValue