Archive Page 2

Microsoft Windows XP EOS Countdown Timer.gadget

Large number of organizations are still using Windows XP.The end of support of this platform is on 2014.

You can check how many days are remaining using the  gadget from Microsoft.

You can download this gadget by  clicking here.

 

image

  • Supported Operating Systems:Windows 7;Windows Vista,Windows 7 32-bit or 64-bit, any edition

VB Script : Remove an entry from Hosts File

 

On Error Resume Next

Set wshshell = createobject("wscript.shell")

Line1="0.0.0.0.0   TEST"
Call RemoveValues(Line1)

 

 

Sub RemoveValues(Line)
    Dim varFile         ‘Variable to store the values of the file
    Dim varFileLines    ‘Variable to store the current line read from the file
    Dim WshShell        ‘Object pointing to the WScript
   
    ‘Initializing the WScript object
    Set WshShell = CreateObject("WScript.shell")
    ‘System root
    SysRoot = WshShell.ExpandEnvironmentStrings("%SystemRoot%")
    ‘File Path
    sFileName = SysRoot & "\system32\drivers\etc\Hosts"
  
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(sFileName, 1)
   
    ‘looping through the Hostss file
    Do Until objFile.AtEndOfStream
        ‘Reading a line from the Hosts file
        varFileLines = objFile.ReadLine
        ‘Checking for the search string
        If Trim(varFileLines) <> Line Then
            ‘Building the string without the search string
            If Trim(varFile) = "" Then
                varFile = Trim(varFileLines)
            Else
                varFile = varFile & vbCrLf & Trim(varFileLines)
            End If
        End If
    Loop
    ‘Closing the file object
    objFile.Close
    Set objFile = Nothing
    ‘Creating the file without the search string
    Set objFile = objFSO.CreateTextFile(sFileName, True, False)
    ‘Writing the lines into the file
    objFile.WriteLine varFile
    ‘Closing the file object
    objFile.Close
    Set objFile = Nothing
End Sub

VB Script:Add an entry in Hosts file

The hosts file is one of several system facilities to assist in addressing network nodes in a computer network.(As per the definition in Wikipedia!)
The hosts file contains lines of text consisting of an IP address in the first text field followed by one or more hostnames.

This file will be present in %SystemRoot%\system32\drivers\etc\

 

The below script is an example for adding an entry in to the hosts file.

This will append the existing hosts file. The same script can be used for updating the services file by changing the filename in the script.

No shy to say this is a copied script !!. I have modified some lines as per our requirement.

 

On Error Resume Next

Dim wshshell

Set wshshell = createobject("wscript.shell")

Line1="0.0.0.0  TEST"     ‘Enter the required entry here
Call AddValues(Line1)

Set wshShell = Nothing

 

Sub AddValues(Line)
    Dim varFile         ‘Variable to store the values of the file
    Dim varFileLines    ‘Variable to store the current line read from the file
    Dim WshShell        ‘Object pointing to the WScript
   
    ‘Initializing the WScript object
    Set WshShell = CreateObject("WScript.shell")
    ‘System root
    SysRoot = WshShell.ExpandEnvironmentStrings("%SystemRoot%")
    ‘File Path
    sFileName = SysRoot & "\system32\drivers\etc\Hosts"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(sFileName,1)

    Flag=0
   
    ‘looping through the hosts file
    Do Until objFile.AtEndOfStream
        ‘Reading a line from the hosts file
        varFileLines = objFile.ReadLine
        ‘Checking for the search string
        If Trim(varFileLines) <> Line Then
            ‘Building the string without the search string
            If Trim(varFile) = "" Then
                varFile = Trim(varFileLines)
            Else
                varFile = varFile & vbCrLf & Trim(varFileLines)
            End If
    Else
        Flag=1
        End If
    Loop
    ‘varFile = varFile & vbCrLf & Trim(varFileLines)
     ‘Closing the file object
        objFile.Close
    if Flag=0 then
        ‘varFile = varFile & vbCrLf & Trim(varFileLines) & vbCrLf & Line
        varFile = varFile & vbCrLf & Line
        ‘Creating the file with the search string
        Set objFile = objFSO.CreateTextFile(sFileName, True, False)
        ‘Writing the lines into the file
        objFile.WriteLine varFile
    ‘Closing the file object
    objFile.Close
    end if
    Set objFile = Nothing
End Sub

%~z1

%~z1 – expands %1 to size of file

To get the size of a file in bytes using batch script is very easy.

Open note pad and type in the below commands.

echo %~z1

pause

save the file as test.bat

If you want to get the size of a file ,say “Testmysize.mdb” ,Open cmd.exe and run the below command.

test.bat Testmysize.mdb

It will display the size of Test my size.mdb file in bytes.

Windows 7: Deploying Your Application with Windows Installer (MSI) and ClickOnce

image

If you are a developer involved in the creation of application deployment packages using Windows Installer (MSI) or ClickOnce, this session is for you… I felt this is very interesting talk.Thanks to Tyler Robinson.

http://channel9.msdn.com/blogs/pdc2008/pc42

Internet Explorer Administration Kit (IEAK)

image

The Internet Explorer Administration Kit (IEAK) simplifies the creation, deployment and management of customized Internet Explorer packages. The IEAK can be used to configure the out-of-box Internet Explorer experience or to manage user settings after Internet Explorer deployment.

Read more about this in the below link.

http://technet.microsoft.com/en-us/ie/bb219517

VB Script :Write a binary value in registry

Here I share with a you a sample script to write a binary value in registry.Its not  easy as you write REG_DWORD ,etc .

const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\test"
strComputer = "."
iValues = Array(&H01) ‘<-Give the value here .

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
BinaryValueName = "FailureActions"
oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath, BinaryValueName,iValues

 

Note: For testing this script make sure ‘HKLM\Software\test’ key present already.