Class ReadInifile
Dim arrFile()
Dim objFSO, objFile
Function sec_prop(section_name,section_property)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("dataexg.ini", 1)
Do Until objFile.AtEndOfStream
str_sec = objFile.ReadLine
If str_sec = "["& section_name & "]" Then
svalue = ""
Do until InStr(svalue,"[") Or objFile.AtEndOfStream
Redim Preserve arrFile(0)
'MsgBox section_name & section_property
If Not objFile.AtEndOfStream Then
arrFile(0) = objFile.ReadLine
'MsgBox InStr(arrFile(0),section_property)
If InStr(arrFile(0),section_property) Then
a = Split(arrFile(0),"=")
sec_prop = a(1)
end If
svalue = arrFile(0)
End If
Loop
End If
Loop
Erase arrFile
objFile.close
End function
End Class
Dim objINI, Result
Set objINI = New ReadInifile
Result = objINI.sec_prop( "server","servername")
MsgBox Result
Tuesday, February 12, 2008
Program to send E-mail through VBScript
Function SendMail(SendTo, Subject, Body, Attachment)
Set ol=CreateObject("Outlook.Application")
Set Mail=ol.CreateItem(0)
Mail.to=SendTo
Mail.Subject=Subject
Mail.Body=Body
If (Attachment <> "") Then
Mail.Attachments.Add(Attachment)
End If
Mail.Send
Set Mail = Nothing
Set ol = Nothing
End Function
Call SendMail(("adityajoy58@gmail.com;kalyan_kudapa@adp.com"),"hi","HI This is Aditya","") //
Set ol=CreateObject("Outlook.Application")
Set Mail=ol.CreateItem(0)
Mail.to=SendTo
Mail.Subject=Subject
Mail.Body=Body
If (Attachment <> "") Then
Mail.Attachments.Add(Attachment)
End If
Mail.Send
Set Mail = Nothing
Set ol = Nothing
End Function
Call SendMail(("adityajoy58@gmail.com;kalyan_kudapa@adp.com"),"hi","HI This is Aditya","") //
Friday, February 8, 2008
How to Get Free space/Total space of Given Drive using VBScript
Dim a,s,t
Call GetFreeSpace("C:")
Wscript.echo s
Function GetFreeSpace(drvPath)
dim fs, d
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(drvPath))
s = "Drive " & drvPath & " - "
s = s & d.VolumeName
s = s & " Free Space: " & d.FreeSpace/1024 & " Kbytes"
s = s & " Total Space: " & d.TotalSize/1024 & "Kbytes"
GetFreeSpace = s
'MsgBox s
End function
Call GetFreeSpace("C:")
Wscript.echo s
Function GetFreeSpace(drvPath)
dim fs, d
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(drvPath))
s = "Drive " & drvPath & " - "
s = s & d.VolumeName
s = s & " Free Space: " & d.FreeSpace/1024 & " Kbytes"
s = s & " Total Space: " & d.TotalSize/1024 & "Kbytes"
GetFreeSpace = s
'MsgBox s
End function
How to Open Internet Explorer with particular site using VBScript
Option Explicit
Dim objIE
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.FullScreen = False
.Navigate "http://www.igoogle.com/"
Do Until .ReadyState <> 4
WScript.Sleep 10000
Loop
End With
Set objIE = Nothing
Dim objIE
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.FullScreen = False
.Navigate "http://www.igoogle.com/"
Do Until .ReadyState <> 4
WScript.Sleep 10000
Loop
End With
Set objIE = Nothing
How to Open any Windows Application using Vbscript
In this Program, we are opening a Windows calculator
set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "calc"
WScript.Sleep 10000
oShell.AppActivate "Calculator"
MsgBox ScriptEngineBuildVersion //For knowing which Script Engine we are using.
set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "calc"
WScript.Sleep 10000
oShell.AppActivate "Calculator"
MsgBox ScriptEngineBuildVersion //For knowing which Script Engine we are using.
How to Open a Windows Application using Vbscript Program
In this Example, we are opening windows calculator
set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "calc"
WScript.Sleep 10000
oShell.AppActivate "Calculator"
MsgBox ScriptEngineBuildVersion // This line shows which version is the Script Engine in XP
set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "calc"
WScript.Sleep 10000
oShell.AppActivate "Calculator"
MsgBox ScriptEngineBuildVersion // This line shows which version is the Script Engine in XP
Wednesday, January 30, 2008
Program to Create a shortcut of a file(.exe) using VBScript
'Creating a desktop icon
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk")
oShellLink.TargetPath = WScript.ScriptFullName
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+F"
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk")
oShellLink.TargetPath = WScript.ScriptFullName
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+F"
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save
Subscribe to:
Posts (Atom)