Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

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","") //

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

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

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.

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

Wednesday, January 30, 2008

Program to Handle windows Processes and kill when required using VBScript.

FriendZ this is to maintain the windows processes with out own logic without bothering with self -scheduling windows tasks.

sComputer ="."
Set oWMI = GetObject("winmgmts:\\" & sComputer & "\root\CIMV2")
Object_OnTimer7510
Sub Object_OnTimer7510
sTotalHandle = 0
sTotalThread = 0
Set oWin32_OS = oWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each oItem In oWin32_OS
'sTotalHandle= oItem.TotalHandle
sFreePhysicalMemory = oItem.FreePhysicalMemory
sFreeVirtualMemory = oItem.FreeVirtualMemory
sTotalProcesses = oItem.NumberOfProcesses
sTotalVirtualMemorySize = oItem.TotalVirtualMemorySize
sTotalVisibleMemorySize = oItem.TotalVisibleMemorySize
Next
sSystemCache = sTotalVisibleMemorySize - sFreePhysicalMemory
sCommitLimit = sTotalVirtualMemorySize - sTotalVisibleMemorySize
text1= VbCrLf & "sTotalHandle :" & Space(16-Len(sTotalHandle))& sTotalHandle & VbCrLf & "sTotalThread :" & Space(16-Len(sTotalThread)) & sTotalThread & VbCrLf & "sTotalProcesses :" & Space(16-Len(sTotalProcesses)) & sTotalProcesses & VbCrLf & "sTotalVisibleMemorySize:" & Space(16-Len(sTotalVisibleMemorySize)) & sTotalVisibleMemorySize & VbCrLf & "sFreePhysicalMemory:" & Space(16-Len(sFreePhysicalMemory)) & sFreePhysicalMemory & VbCrLf & "sSystemCache :" & Space(16-Len(sSystemCache)) & sSystemCache & Space(16) & VbCrLf & "sCommitLimit :" & Space(16-Len(sCommitLimit)) & sCommitLimit & Space(16)
MsgBox text1
set servicelist = oWMI.ExecQuery("Select * from Win32_Process")
For Each service in servicelist
sname = sname & service.ProcessId & ":" & lcase(service.name) & Space(1)
'MsgBox service.name
Next
MsgBox sname
xml_file = InputBox("Enter which file you have to termimate :")
flag=True
For Each service in servicelist
If service.name = xml_file Then
service.Terminate()
flag= false
End if
Next
If flag then
MsgBox "File Name dose not exist"
Else
MsgBox xml_file & " process terminated"
End If
Set oWMI = Nothing
Set oWin32_OS = Nothing
Set servicelist = Nothing
End Sub