venerdì 30 ottobre 2009

Wincheck Online on Google AppEngine

sabato 24 ottobre 2009

Available memory from Vbs

Available memory from Vbs
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colCSItems = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem")
For Each objCSItem In colCSItems 
WScript.Echo "Total Physical Memory: " &
objCSItem.TotalPhysicalMemory
Next
Set colOSItems = objWMIService.ExecQuery("SELECT * FROM
Win32_OperatingSystem")
For Each objOSItem In colOSItems 
WScript.Echo "Free Physical Memory: " &
objOSItem.FreePhysicalMemory 
WScript.Echo "Total Virtual Memory: " &
objOSItem.TotalVirtualMemorySize 
WScript.Echo "Free Virtual Memory: " &
objOSItem.FreeVirtualMemory 
WScript.Echo "Total Visible Memory Size: " &
objOSItem.TotalVisibleMemorySizeNext

Vbs starts Windows Services

This script start windows Service :

set myServices = GetObject("winmgmts:")
set myObject = myServices.Get("Win32_Service.Name='MSSQLSERVER'")
myObject.StartService()

IE vbs robot Browser - reading key in text file

Read text file named "Cerca.txt

On Error Resume Next
DO
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile( "Cerca.txt", 1, False, 0)
Do While file.AtEndOfStream <> True
set objExplorer=WScript.CreateObject("InternetExplorer.Application","objExplorer_")
objExplorer.navigate2("http://www.google.it")
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1
Do Until
objExplorer.ReadyState=4
WScript.Sleep inti*100*Rnd()
Loop
objExplorer.Document.All.Item("q").Value = file.ReadLine
objExplorer.Document.All.Item("sa").Click
Do Until
objExplorer.ReadyState=4
WScript.Sleep inti*100*Rnd()
Loop
WScript.Sleep
inti*100*Rnd()
Loop
objExplorer.Quit
file.Close()
Set file=Nothing
Set fso=Nothing
inti = inti + 1
Loop Until inti = 1300
Wscript.Quit
 

Massive string in file sustitution by vbs script

Massive string in file sustitution by vbs script :


' Script per Sostituzione di massa stringhe in file

' Massive text in file substution

Set oFSO = CreateObject("Scripting.FileSystemObject")Set
objShell = WScript.CreateObject( "WScript.Shell" )
Set fOut = oFSO.CreateTextFile("StringInFileSubstitution.txt", True)
Dim FileName, Find,
ReplaceWith, FileContents, dFileContents, PathDir

Dim NomeP

Dim OutPut


'Modifica file nella cartella
Find = Inputbox ("Inserisci la stringa da cercare nei file","The Patcher","pippo")
ReplaceWith = Inputbox ("Inserisci la stringa da sostituire a " + Find ,"The Patcher","pippa")
PathDir = Inputbox ("Inserisci il path da cui partire","The
Patcher","C:\Test1")
DoStuff oFSO.GetFolder(PathDir).Path,Find,ReplaceWith

'Read text file

function Fix(FileName, Find, ReplaceWith)
'Read source text
fileFileContents = GetFile(FileName)
'replace all string In the source
filedFileContents = replace(FileContents, Find, ReplaceWith, 1, -1, 1)
'Compare source And result

if dFileContents <> FileContents
Then

'write result If different

WriteFile FileName, dFileContents
If Len(ReplaceWith) <> Len(Find) Then 'Can we
count n of replacements? fOut.WriteLine "DB " & FileName & "
file Fixed." fOut.WriteLine _ (
(Len(dFileContents) - Len(FileContents)) / (Len(ReplaceWith)-Len(Find)) ) &
_ " fixes Applied."

End

IfElse ' fOut.WriteLine "No
Fixes Applied to source file " & FileNameEnd If
End Function

'Read text file

function GetFile(FileName)

If FileName<>""
Then Dim FS, FileStream Set FS =
CreateObject("Scripting.FileSystemObject")

on error resume Next

Set FileStream = FS.OpenTextFile(FileName)

GetFile = FileStream.ReadAll End IfEnd Function
'Write string As a text file.

function WriteFile(FileName, Contents)

Dim OutStream, FS
on error resume Next

Set FS = CreateObject("Scripting.FileSystemObject")

Set OutStream = FS.OpenTextFile(FileName, 2, True)

OutStream.Write Contents

End

Function Sub DoStuff(sDir,Find,ReplaceWith)

fOut.WriteLine sDirSet

oDir = oFSO.GetFolder(sDir)
For Each i In oDir.Filesf=Fix(i.Path, Find, ReplaceWith)

Next
For Each i In oDir.SubFolders

DoStuff i.Path,Find,ReplaceWithNext
fOut.WriteLine ""'

For Each i In oDir.SubFolders'DoStuff i.Path'

Next

End Sub


domenica 4 ottobre 2009

RDP command Connect to Console session

mstsc 1 -v:server /F -console /admin

sabato 16 maggio 2009

Oracle PL/SQL dual Table

Create update script of TABLEA based on fields of TABLEB.

Oracle PL/Sql Script :

set heading off
set pagesize 50000
set echo off
set trims on
set verify off
set feed off
set linesize 2000 

Spool &&FILE_NAME; select '-- Dati creati il 'to_char(sysdate,'dd/mm/yyyy hh24:mi') from dual; select '-- Inzio Scarico Tabella -- ' from dual; select 'update TABLEA set FIELDA=' FIELDB ' WHERE KEYA=''CHIAVE"; ' FROM TABLEB &&WHERE_CLAUSEB. ; select '-- Fine Scarico Tabella -- ' from dual;   select 'exit;' from dual; Spool off;