strComputer = InputBox (" Please Enter the Computer Name to Know the Service Tag Number",_
"Enter Computer Name")
Set oWMI = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
Set oCol = oWMI.ExecQuery("Select * from Win32_ComputerSystemProduct")
For Each x in oCol
wscript.echo " The service Tag is : " & x.IdentifyingNumber
Next
My Favourite Videos
Wednesday, January 16, 2008
VB SCRIPTS
Posted by
freecoolstuffs
at
8:17 PM
0
comments
Labels: Scripting
MAILING FROM VBSCRIPT (Triggering a Mail from VBscript using your Public POP enabled account)
Function SendMail()
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "Admin@someOne.com"
objEmail.To = " Admin@someOne.com "
objEmail.CC = " Admin@someOne.com "
objEmail.Subject = "Sent through VBscript--> ack once received: Thanx"
objEmail.TextBody = " This mail is sent through VBscript invoking the SMTP of Gmail and using the Gmail username and passwords"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "http://127.0.0.1"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Your POP Enabled account"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Your POP Enabled account Password"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendserverport") = 587
objEmail.Configuration.Fields.Update
objEmail.Send
' if objEmail.Send <> True then
'Wscript.Echo "Email sent"
'else
'Wscript.Echo "Email not sent"
'end if
End Function
Posted by
freecoolstuffs
at
7:52 AM
0
comments
Labels: Scripting
CHECK FOR A PIRTICULAR SERVICE IS AVAILABLE OR NOT And PIPING OUT THE RESULT IN A EXCEL FILE
On Error Resume Next
Set ObjShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ObjInputFile = fso.OpenTextFile("c:\Machines.txt", 1, True)
Set ObjOutputFile = fso.OpenTextFile("c:\Result.xls", 2, True)
ObjOutputFile.WriteLine "Server Name " & vbTab & "Is Agent Present"
Do While ObjInputFile.AtEndOfLine <> True
strComputer = ObjInputFile.Readline
WScript.Echo "Working on --> " & strComputer
Set objScriptExec = objShell.Exec("Ping -n 2 -w 1000 " & strComputer )
strPingResults = LCase(ObjScriptExec.StdOut.ReadAll)
If InStr(strPingResults,"reply from") Then
Set ObjWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")
Set ColService = ObjWMIService.ExecQuery("SELECT * FROM Win32_Service
WHERE Name =' Alerter'")
If ColService.Count = 0 Then
ObjOutputFile.WriteLine strComputer & vbTab & "NO"
End if
For Each Service In ColService
ObjOutputFile.WriteLine strComputer & vbTab & "Yes"
Next
Else
ObjOutputFile.WriteLine strComputer & vbTab & "Unable to Conenct the Server
Or the Server Down"
End if
Loop
WScript.Echo " script Completed"
Posted by
freecoolstuffs
at
7:46 AM
0
comments
Labels: Scripting
RESTART A REMOTE COMPUTER
' Restart a Computer
strComputer = InputBox (" Please Enter the Computer Name to restart ",_
"Enter Computer Name")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
'issue shutdown to OS'
4 = force logoff
' 5 = force shutdown
' 6 = force rebooot
' 12 = force power off
Number = InputBox(" Enter the Number" & vbCrLf & vbCrLf & "4 = Force logoff"
& vbCrLf & "5 = Force shutdown" & vbCrLf & "6 = Force rebooot" & vbCrLf & "12
= Force power off", "What you Want to Do")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Win32ShutDown(Number)
WScript.Echo "The Requested Operation is Performed in " & strComputer
Next
digg_url="http://syztemlabs.blogspot.com/2007/11/restart-remote-computer.html";
Posted by
freecoolstuffs
at
7:41 AM
0
comments
Labels: Scripting
GETTING THE SHARE DETAILS OF A COMPUTER
strComputer = InputBox (" Please Enter the Computer Name to Know the Share
Details",
_"Enter Computer Name")
Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colShare = objWMIService.ExecQuery
_("Select * from Win32_Share")
For Each Share In colShare
WScript.Echo " Share Path : " & Share.path & vbTab & vbTab & vbTab & vbTab &" Share location: " & Balaji.Caption
Next
WScript.Sleep 10000
Posted by
freecoolstuffs
at
7:37 AM
0
comments
Labels: Scripting
RECYCLING THE APPLICATION POOL
On Error Resume Next
strComputer = InputBox _
("Please enter the name of the Computer where ‘XXXXX’ to be Recycled:", _
"Enter ComputerName Name")
if strComputer = "" Then
Wscript.Quit
End If
strUser = InputBox _
("Please enter the UserName:", "Enter UserName")
strPassword = InputBox _
("Please enter the Password:", "Enter Password")
PoolName = InputBox ("Please Enter the Name of the Application Pool :", "Application Pool Name")
Set LocatorObj = CreateObject("WBemScripting.SWbemLocator")
LocatorObj.Security_.ImpersonationLevel = 3
LocatorObj.Security_.AuthenticationLevel = 6
Set ProviderObj = LocatorObj.ConnectServer(strComputer, "\root\microsoftiisv2", strUser, strPassword)
Set colItems = ProviderObj.ExecQuery _
("Select * From IIsApplicationPool Where Name = " & _
"'W3SVC/AppPools/Enter the Application Pool Name'")
For Each objItem in colItems
objItem.Recycle
On Error Goto 0
WScript.Echo "The Application Pool in " & strComputer & " is Recycled"
Next
Posted by
freecoolstuffs
at
7:33 AM
0
comments
Labels: Scripting