Jump to content

Recommended Posts

Posted (edited)

I wrote this script as a Demo of the Send Key that VBS has

What it does

1:\ Opens Notepad.exe

2:\ Types in some basic Computer Information

3:\ Saves the text file using Send Key

4:\ Closes the file using Send Key

'/-> Varibles	: Objects For The Script
Dim StrComputer : StrComputer = "."
Dim Act : Set Act = CreateObject("WScript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim objWMI : Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim Cname : Cname = Act.ExpandEnvironmentStrings("%ComputerName%")
Dim Uname : Uname = Act.ExpandEnvironmentStrings("%UserName%")
Dim VBS : VBS = Act.ExpandEnvironmentStrings("%Systemdrive%\Demo_SendKey.vbs")
Dim Xp1 : Xp1 = Act.SpecialFolders("Desktop")
Dim XpKey : XpKey = Xp1 & "\OsInfo.txt"
Dim H_K : H_K = "HKEY_LOCAL_MACHINE"
Dim KeyXP : KeyXP = H_K & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"
Dim strXPKey : strXPKey = Act.RegRead(H_K & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
Dim MB : MB = 1024
'---------------------------------------------------------------------
'/--> If Exists It Deletes The File So The Script Does Not Get The File Exists Error
'/--> When The Save File Send Key Events Occur
If Fso.FileExists(XpKey) Then Fso.DeleteFile(XpKey) End If
Act.Popup "Preparing to start the Demo Send Keys" & vbCrLf &_
"This runs for approxemently 2 minutes", 7,"Begin Demo", 0 + 64 + 4096
'---------------------------------------------------------------------
'/--> Open Notepad.exe
Act.run "Notepad.exe" : Act.AppActivate "Notepad" :WScript.Sleep 500
'/--> Varibles To Use In The Text Output
Dim ALeft1 : ALeft1 = Space(3) & Chr(60) & Space(1)
Dim Aleft2 : Aleft2 = Chr(62) & Chr(62) & Space(1)
Dim Ln1 : Ln1 = Space(1) & Chr(60) & Chr(60) &_
" -------------------------------------------------------------------------- " & Chr(62) & Chr(62)
'---------------------------------------------------------------------
'/--> Computer System Info
Dim Cp, StrCp
Act.SendKeys Ln1
Act.SendKeys "{ENTER}" : WScript.Sleep 100
Cp = Array(ALeft1 & " C", "o","m","p","u","t","e","r",Space(1),"S","y","s","t","e","m")
'/--> Send The Key Stokes
For Each StrCp In Cp
Act.SendKeys UCase(StrCp) : WScript.Sleep 100
Next
Act.SendKeys Space(2) & Chr(62)
PressEneter() : WScript.Sleep 600
'---------------------------------------------------------------------
'---------------------------------------------------------------------
'/--> User Name
Dim Un, StrUn : Un = Array(ALeft1 & " U","s","e","r",Space(1),"N","a","m","e" ,Space(9))
For Each StrUn In Un
Act.SendKeys StrUN : WScript.Sleep 100
Next
Act.SendKeys Aleft2 & Uname & Space(1) & Chr(62)
PressEneter() : WScript.Sleep 600
'---------------------------------------------------------------------
'/--> Computer Name
Dim Cn, StrCn : Cn = Array(ALeft1 & " C","o","m","p","u","t","e","r",Space(1),"N","a","m","e" ,Space(5))
For Each StrCn In Cn
Act.SendKeys StrCN : WScript.Sleep 100
Next
Act.SendKeys Aleft2 & Cname & Space(1) & Chr(62)
PressEneter() : WScript.Sleep 600
'---------------------------------------------------------------------
'/--> Get The OS Key Copy And Paste
GetKey(Act.RegRead(KeyXP))
'---------------------------------------------------------------------
'/--> Computer Key
Dim Ky, StrKy : Ky = Array(ALeft1 & " C","o","m","p","u","t","e","r"," ", "K","e","y",Space(6))
For Each StrKy In Ky
Act.SendKeys StrKy : WScript.Sleep 100
Next
Act.SendKeys Aleft2 & Key & Space(1) & Chr(62)
PressEneter() : WScript.Sleep 600
'---------------------------------------------------------------------
'/--> Varibles For The Wmi Collection
Dim CPIt, colItems, W1, W2, W3, W4
'---------------------------------------------------------------------
'/--> Operating System Info
Dim Comp, StrComp
Comp_Info
Function Comp_Info()
Act.SendKeys Ln1
Act.SendKeys "{ENTER}" : WScript.Sleep 100
Comp = Array(ALeft1 & " O", "p","e","r","a","t","i","n","g",Space(1),"S","y","s","t","e","m")
For Each StrComp In Comp
Act.SendKeys UCase(StrComp) : WScript.Sleep 100
Next
Act.SendKeys Space(2) & Chr(62)
PressEneter() : WScript.Sleep 600
'---------------------------------------------------------------------
'/--> Wmi Class Win32_OperatingSystem
Set colItems = objWMI.ExecQuery("Select * FROM Win32_OperatingSystem",,48)
For Each objItem in colItems
W1 = objItem.Caption & Space(3) & objItem.Version
W2 = WMIDateStringToDate(objItem.InstallDate)
W3 = objItem.Organization
W4 = Left(Round(objItem.TotalVisibleMemorySize/MB,5),5)
Next
'/--> OS Name And Version
Dim Comp1, Comp1a
Comp1 = Array(Space(5) & "O","S",Space(1),"N","a","m","e",Space(1),"V","e","r","s","i","o","n",Space(3))
For Each Comp1a In Comp1
Act.SendKeys Comp1a : WScript.Sleep 100
Next
CPIt = W1 : CopyPasteIt() : CPIt = ""
'/--> Install Date
Dim Comp2, Comp2a
Comp2 = Array(Space(5) & "O","S",Space(1),"I","n","s","t","a","l","l",Space(1),"D","a","t","e",Space(3))
For Each Comp2a In Comp2
Act.SendKeys Comp2a : WScript.Sleep 100
Next
CPIt = W2 : CopyPasteIt() : CPIt = ""
'/--> Organization
Dim Comp3, Comp3a
Comp3 = Array(Space(5) & "O","r","g","a","n","z","a","t","i","o","n",Space(7))
For Each Comp3a In Comp3
Act.SendKeys Comp3a : WScript.Sleep 100
Next
CPIt = W3 : CopyPasteIt() : CPIt = ""
'/--> Installed Ram
Dim Comp4, Comp4a
Comp4 = Array(Space(5) & "I","n","s","t","a","l","l","e","d",Space(1),"R","a","m",Space(5))
For Each Comp4a In Comp4
Act.SendKeys Comp4a : WScript.Sleep 100
Next
CPIt = W4 : CopyPasteIt() : CPIt = "" : WScript.Sleep 600
End Function
'---------------------------------------------------------------------
'/--> CPU Info
Dim Cpu, StrCpu
CPU_Info
Function CPU_Info()
Act.SendKeys Ln1
Act.SendKeys "{ENTER}" : WScript.Sleep 100
Cpu = Array(ALeft1 & " P","r","o","c","e","s","s","o","r")
For Each StrCpu In Cpu
Act.SendKeys UCase(StrCpu) : WScript.Sleep 100
Next
Act.SendKeys Space(2) & Chr(62)
PressEneter() : WScript.Sleep 600
'---------------------------------------------------------------------
'/--> Wmi Class Win32_Processor
Set colItems = objWMI.ExecQuery("Select * FROM Win32_Processor",,48)
For Each objItem in colItems
W1 = objItem.Manufacturer & Space(3) & objItem.Name
W2 = objItem.CurrentClockSpeed & " MHZ"
W3 = "Size " & Chr(62) & Space(1) & objItem.L2CacheSize & Space(3) &_
"Speed " & Chr(62) & Space(1) & objItem.L2CacheSpeed & " MHZ"
W4 = objItem.Description
Next
'/--> CPU Manufacturer
Dim CPU1, CPU1a
CPU1 = Array(Space(5) & "M","a","n","u","f","a","c","t","u","r","e","r"," ","I","n","f","o",Space(1))
For Each CPU1a In CPU1
Act.SendKeys CPU1a : WScript.Sleep 100
Next
CPIt = W1 : CopyPasteIt() : CPIt = ""
'/--> CPU Clock Speed
Dim CPU2, CPU2a
CPU2 = Array(Space(5) & "C","P","U"," ","C","l","o","c","k"," ","S","p","e","e","d",Space(3))
For Each CPU2a In CPU2
Act.SendKeys CPU2a : WScript.Sleep 100
Next
CPIt = W2 : CopyPasteIt() : CPIt = ""
'/--> CPU L2 Cache
Dim CPU3, CPU3a
CPU3 = Array(Space(5) & "L","2"," ","C","a","c","h","e"," ","I","n","f","o",Space(5))
For Each CPU3a In CPU3
Act.SendKeys CPU3a : WScript.Sleep 100
Next
CPIt = W3 : CopyPasteIt() : CPIt = ""
'/--> CPU Description
Dim CPU4, CPU4a
CPU4 = Array(Space(5) & "C","P","U"," ","D","e","s","c","r","i","p","t","i","o","n",Space(3))
For Each CPU4a In CPU4
Act.SendKeys CPU4a : WScript.Sleep 100
Next
CPIt = W4 : CopyPasteIt() : CPIt = "" : WScript.Sleep 600
End Function
'---------------------------------------------------------------------
'/--> MotherBoard
Dim MBi, StrMBi
MB_Info
Function MB_Info()
Act.SendKeys Ln1 : WScript.Sleep 50
Act.SendKeys "{ENTER}" : WScript.Sleep 100
MBi = Array(ALeft1 & " M", "o","t","h","e","r"," ","B","o","a","r","d")
For Each StrMBi In MBi
Act.SendKeys UCase(StrMBi) : WScript.Sleep 100
Next
Act.SendKeys Space(2) & Chr(62)
PressEneter() : WScript.Sleep 600
'---------------------------------------------------------------------
'/--> Wmi Class Win32_ComputerSystem
Set colItems = objWMI.ExecQuery("Select * FROM Win32_ComputerSystem",,48)
For Each objItem in colItems
W1 = objItem.Manufacturer
W2 = objItem.Model
W3 = objItem.SystemType
W4 = objItem.Description
Next
'---------------------------------------------------------------------
'/--> Mother Board Manufacturer
Dim MBi1, MBi1a
MBi1 = Array(Space(5) & "M","a","n","u","f","a","c","t","u","r","e","r"," ","I","n","f","o",Space(1))
For Each MBi1a In MBi1 : Act.SendKeys MBi1a : WScript.Sleep 100 : Next
CPIt = W1 : CopyPasteIt() : CPIt = ""
'/--> Mother Board Model
Dim MBi2, MBi2a
MBi2 = Array(Space(5) & "M","o","d","e","l"," ","T","y","p","e",Space(8))
For Each MBi2a In MBi2 : Act.SendKeys MBi2a : WScript.Sleep 100 : Next
CPIt = W2 : CopyPasteIt() : CPIt = ""
'/--> Mother Board System Type
Dim MBi3, MBi3a
MBi3 = Array(Space(5) & "S","y","s","t","e","m"," ","T","y","p","e",Space(7))
For Each MBi3a In MBi3 : Act.SendKeys MBi3a : WScript.Sleep 100 : Next
CPIt = W3 : CopyPasteIt() : CPIt = ""
'/--> Mother Board Description
Dim MBi4, MBi4a
MBi4 = Array(Space(5) & "M","B"," "," ","D","e","s","c","r","i","p","t","i","o","n",Space(3))
For Each MBi4a In MBi4 : Act.SendKeys MBi4a : WScript.Sleep 100 : Next
CPIt = W4 : CopyPasteIt() : CPIt = "" : WScript.Sleep 600
End Function
'---------------------------------------------------------------------
'/--> Page File
Dim PF, StrPF
PageFile_Info
Function PageFile_Info()
Act.SendKeys Ln1
Act.SendKeys "{ENTER}" : WScript.Sleep 100
PF = Array(ALeft1 & " P","a","g","e"," ", "F","i","l","e")
For Each StrPF In PF
Act.SendKeys UCase(StrPF) : WScript.Sleep 100
Next
Act.SendKeys Space(1) & Chr(62)
PressEneter() : WScript.Sleep 600
'---------------------------------------------------------------------
'/--> Wmi Class Win32_PageFileUsage
Set colItems = objWMI.ExecQuery("Select * FROM Win32_PageFileUsage",,48)
For Each objItem in colItems
W1 = objItem.AllocatedBaseSize & " MB"
W2 = objItem.PeakUsage & " MB"
W3 = objItem.CurrentUsage & " MB"
W4 = objItem.Description
Next
'---------------------------------------------------------------------
'/--> Add The Page File Size
Dim PF1, PF1a : PF1 = Array(Space(5) & "T","o","t","a","l"," " ,"S","i","z","e",Space(8))
For Each PF1a In PF1 : Act.SendKeys PF1a : WScript.Sleep 100 : Next
CPIt = W1 : CopyPasteIt() : CPIt = ""
'/--> Add The Page File In Usage
Dim PF2, PF2a : PF2 = Array(Space(5) & "P","e","a","k"," ","U","s","a","g","e",Space(8))
For Each PF2a In PF2 : Act.SendKeys PF2a : WScript.Sleep 100 : Next
CPIt = W2 : CopyPasteIt() : CPIt = ""
'/--> Add The Page File Peak Usage
Dim PF3, PF3a : PF3 = Array(Space(5) & "C","u","r","r","e","n","t",space(11))
For Each PF3a In PF3 : Act.SendKeys PF3a : WScript.Sleep 100 : Next
CPIt = W3 : CopyPasteIt() : CPIt = ""
'/--> Add The Page File Location
Dim F4, F4a : PF4 = Array(Space(5) & "L","o","c","a","t","i","o","n",space(10))
For Each PF4a In PF4 : Act.SendKeys PF4a : WScript.Sleep 100 : Next
CPIt = W4 : CopyPasteIt() : CPIt = "" : WScript.Sleep 600
WScript.Sleep 1000
End Function
'---------------------------------------------------------------------
'/--> Start The Save The File Send Key Strokes
Dim Save, StrSave
SaveTxt
Function SaveTxt()
Dim Loc, StrLoc : Loc = Array(ALeft1 & " O", "s","I","n","f","o",".","t","x","t",Space(1),"H","e","r","e",Space(3))
Act.SendKeys Ln1 : PressEneter() : WScript.Sleep 50
For Each StrLoc In Loc
Act.SendKeys StrLoc : WScript.Sleep 100
Next
Act.SendKeys Aleft2 & XpKey & Space(1) & Chr(62)
PressEneter() : WScript.Sleep 1600
Save = Array("{ENTER}", "{F10}", "{ENTER}", "{DOWN}","{DOWN}", "{DOWN}","{ENTER}","^+s", XpKey,"{ENTER}")
For Each StrSave In Save
Act.SendKeys StrSave : WScript.Sleep 500
Next
WScript.sleep 500
End Function
'---------------------------------------------------------------------
'/--> Start The Exit Notepad Send Key Strokes
Dim Fin, StrFin
ExitTxt
Function ExitTxt()
Fin = Array("{F10}","{ENTER}","{DOWN}","{DOWN}","{DOWN}","{DOWN}","{DOWN}","{DOWN}","{ENTER}")
For Each StrFin In Fin
Act.SendKeys StrFin : WScript.Sleep 500
Next
End Function
'---------------------------------------------------------------------
'/--> Varible For The Get The Key
Dim rpk,Key, IeCPit
'/--> Get The Key
Function GetKey(rpk)
Const rpkOffset=52:i=28
szPossibleChars="BCDFGHJKMPQRTVWXY2346789"
Do
dwAccumulator=0 : j=14
Do
dwAccumulator=dwAccumulator*256
dwAccumulator=rpk(j+rpkOffset)+dwAccumulator
rpk(j+rpkOffset)=(dwAccumulator\24) and 255
dwAccumulator=dwAccumulator Mod 24
j=j-1
Loop While j>=0
i=i-1 : szProductKey=mid(szPossibleChars,dwAccumulator+1,1)&szProductKey
If (((29-i) Mod 6)=0) And (i<>-1) Then
i=i-1 : szProductKey="-"&szProductKey
End If
Loop While i>=0
GetKey=szProductKey
Key = szProductKey
End Function
'---------------------------------------------------------------------
'/--> Conert The Date
Function WMIDateStringToDate(dtmDate)
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
'---------------------------------------------------------------------
'/--> Copy The End Double Arrow And Paste It
Function CopyPasteIt()
Act.SendKeys Space(1) & Chr(62) & Chr(62) : WScript.Sleep 50
Act.SendKeys " " & CPIt : WScript.Sleep 800
Act.SendKeys "{ENTER}" : WScript.Sleep 100
End Function
'---------------------------------------------------------------------
'/--> Send Key Press Enter
Function PressEneter()
' Act.SendKeys "^+V" : WScript.Sleep 100
Act.SendKeys "{ENTER}" : WScript.Sleep 150
End Function
'/--> Delete The VBS File If Ran From The SFX File
If Fso.FileExists(VBS) Then Fso.DeleteFile(VBS), True

The text file it makes

<< -------------------------------------------------------------------------- >>
< COMPUTER SYSTEM >
< User Name >> Gunsmokingman >
< Computer Name >> VISTAHOME2006 >
< Computer Key >> Key Information Here >
<< -------------------------------------------------------------------------- >>
< OPERATING SYSTEM >
OS Name Version >> Microsoft Windows Vista Ultimate 6.0.5472
OS Install Date >> 7/17/2006 8:09:00 PM
Organzation >> Home-Beta-2004
Installed Ram >> 511.4
<< -------------------------------------------------------------------------- >>
< PROCESSOR >
Manufacturer Info >> AuthenticAMD Pro3100A
CPU Clock Speed >> 1672 MHZ
L2 Cache Info >> Size > 256 Speed > 557 MHZ
CPU Description >> x86 Family 6 Model 8 Stepping 0
<< -------------------------------------------------------------------------- >>
< MOTHER BOARD >
Manufacturer Info >> ECS
Model Type >> L7VMM3
System Type >> X86-based PC
MB Description >> AT/AT COMPATIBLE
<< -------------------------------------------------------------------------- >>
< PAGE FILE >
Total Size >> 768 MB
Peak Usage >> 384 MB
Current >> 270 MB
Location >> E:\pagefile.sys
<< -------------------------------------------------------------------------- >>
< OsInfo.txt Here >> E:\Users\Gunsmokingman\Desktop\OsInfo.txt >

Demo_SendKey.exe

Edited by gunsmokingman

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...