Friday, 15 June 2012
Increment ActiveSetup Version - VBScript
'This script will create the Active setup if not present on the system, otherwise it will increment the version of the active setup
' Need to replace the "Any that you want to run" with the exact path of the EXE/MSI/Script which has to run
' Replace the "<NameOfActiveSetup>" with the related unique application name
Option Explicit
On Error Resume Next
Dim WshShell ,PrgFiles,KeyValue
Set WshShell=CreateObject("WScript.Shell")
KeyValue=WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\Version")
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\StubPath", "Any that you want to run"
'Err.Clear
If Err.Number=0 Then
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\Version",KeyValue+1,"REG_SZ"
Else
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\Version","1","REG_SZ"
End If
Set WshShell = Nothing
Set PrgFiles = Nothing
WScript.Quit
Get current directory - VBScript
on Error Resume Next
Set objWshShell = CreateObject("WScript.Shell")
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
sScriptDir=objFileSystem.GetParentFolderName(WScript.ScriptFullName)
msgbox sscriptdir
Hide ARP Entry of MSI
use following script to Hide ARP entry of an MSI
Dim WSHShell,strRegKey
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.Regwrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\<ProductCode>\SystemComponent","1","REG_DWORD"
Dim WSHShell,strRegKey
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.Regwrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\<ProductCode>\SystemComponent","1","REG_DWORD"
Check Free Disk Space - VBScript
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_LogicalDisk WHERE DeviceID = 'C:'",,48)
For Each objItem in colItems
Bytes = objItem.FreeSpace
If Bytes >= 1073741824 Then
SetBytes = Round(FormatNumber(Bytes / 1024 / 1024 / 1024, 2), 0) & " GB"
ElseIf Bytes >= 1048576 Then
SetBytes = Round(FormatNumber(Bytes / 1024 / 1024, 2), 0) & " MB"
ElseIf Bytes >= 1024 Then
SetBytes = Round(FormatNumber(Bytes / 1024, 2), 0) & " KB"
ElseIf Bytes < 1024 Then
SetBytes = Bytes & " Bytes"
Else
SetBytes = "0 Bytes"
End If
Wscript.Echo "OUTPUT = " & SetBytes
Next
SendKeys VBscript Example
On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
strWindowNameEN = "PictureTaker Personal Edition"
successEN = False
Do
successEN = WshShell.AppActivate(strWindowNameEN)
Loop Until (successEN = True)
If (successEN) Then
WshShell.AppActivate strWindowNameEN
End IF
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
Thursday, 14 June 2012
Install MSI using WiseScript
Following script installs sample.msi located in the location where wisescript EXE is located.
Declaration of Variables
-> Set Variable MSI to "Path of MSI"
-> Set Variable MSIEXEC to "path of msiexec.exe file present in system32 folder"
then execute MSI installation command
-> Execute Program, provide the executable to run along with command line arguments
-> Ouput WiseScriptEXE needs Sample.msi to be present beside to perform MSI installation
Declaration of Variables
-> Set Variable MSI to "Path of MSI"
-> Set Variable MSIEXEC to "path of msiexec.exe file present in system32 folder"
then execute MSI installation command
-> Execute Program, provide the executable to run along with command line arguments
-> Ouput WiseScriptEXE needs Sample.msi to be present beside to perform MSI installation
Delete Registries using Wise Script
Deleting registries along with hive using WiseScript.
-> Use the function, "Edit Registry" and import the registry that needs to be deleted
-> Under Operation, Select "Remove Key and all sub Keys" for any registry under that hive
-> In the following example, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Communicator and all registry keys under Communicator will be deleted using following script.
-> Use the function, "Edit Registry" and import the registry that needs to be deleted
-> Under Operation, Select "Remove Key and all sub Keys" for any registry under that hive
-> In the following example, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Communicator and all registry keys under Communicator will be deleted using following script.
Subscribe to:
Posts (Atom)