Pages

Thursday, 2 August 2012

Get Network Adaptor Speed - VBSCript


strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\WMI") 
Set colItems = objWMIService.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48) 
For Each objItem in colItems 
    Wscript.Echo "InstanceName: " & objItem.InstanceName
    Wscript.Echo "NdisLinkSpeed: " & objItem.NdisLinkSpeed/10000 & " mbps"
Next


Copying a Set of Files - VBScript



Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\FSO\*.txt" , "D:\Archive\" , OverwriteExisting

Read Registry - VBScript


Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\./root/default:StdRegProv")
sBaseKey = "SOFTWARE\"
iRC = oRegistry.EnumKey(&H80000001, sBaseKey, arSubKeys)
For Each sKey In arSubKeys

if skey="JNJ" then
msgbox "yes"
end if
next

Check Drive Letter in Use - VBScript



Dim Wdrive
Set FileSystemObject = wscript.CreateObject("scripting.FileSystemObject")
Set Drives = FileSystemObject.Drives 'Create a drives collection

For Each DiskDrive in Drives
DriveLetter = DiskDrive.DriveLetter
If DriveLetter = W Then
Wdrive = True
wscript.echo "W Mapped"
End If
Next

Add Lines to File - VBSCript


Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\oracle\ora81\network\admin\tnsnames.ora", ForReading)

Do Until objTextFile.AtEndOfStream
    strLine = objTextFile.ReadLine
    intFailure = InStr(strLine, "LINE 1")
    intFailure2 = InStr(strLine, "LINE 2")
    intfailure3 = InStr(strLine, "LINE 3")
    intfailure4 = InStr(strLine, "LINE 4")
    intfailure5 = InStr(strLine, "LINE 5")
    intfailure6 = InStr(strLine, "LINE 6")
    intfailure7 = InStr(strLine, "LINE 7")

    If intFailure > 0 or intFailure2 > 0 or intFailure3 > 0 or intFailure4 > 0 or intFailure5 > 0 or intFailure6 > 0 intFailure7 > 0 Then
        strNewText = strNewText & strLine & vbCrLf
    Else
        strOtherNewText = strOtherNewText & strLine & vbCrLf
    End If
Loop

objTextFile.Close
Set objTextFile = objFSO.OpenTextFile("C:\oracle\ora81\network\admin\tnsnames.ora", ForWriting, True)
objTextFile.Write(strOtherNewText)
objTextFile.Close

'****************************************************************************************************************

dim filesys, filetxt
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile("C:\oracle\ora81\network\admin\tnsnames.ora", ForAppending, True)
filetxt.WriteLine("LINE 1")
filetxt.WriteLine("LINE 2")
filetxt.WriteLine("LINE 3")
filetxt.WriteLine("LINE 4")
filetxt.WriteLine("LINE 5")
filetxt.WriteLine("LINE 6")
filetxt.WriteLine("LINE 7")
filetxt.Close

Set Shortcut Icon - VBScript


Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFld = objShell.SpecialFolders("Desktop")
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\blah.url")
objURLShortcut.TargetPath = "http://www.blah.com"
objURLShortcut.IconLocation "\\server\share\icon.ico
objURLShortcut.Save 

Wednesday, 1 August 2012

Adding Pre-Requisite along with Setup - Installshield

In order to check and install a pre-requisite along with setup. Follow the steps:




1. Goto Application Data -> Redistributables in Installation Designer


2. Select the pre-requisite that needs to be added to setup installation.


3. Select when pre-requisite installation should happen incase if its not found.