About · Site feedback
welcome  Products  Scripts  Downloads  Forum  Contact us  Support  Resellers 
 
Scripts
 
PHP
JavaScript
Visual Basic
 
External downloads
If you use WSH or just VBScript / JScript, then the most important download to have is the Windows script host documentation (version 5.6).
 
Legal information
End User License Agreement
Non-commercial license
Disclaimer and legal notice
 
 

System VB scripts

 

Get information from the registry

const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
'Get a DWORD value
strKeyPath = "Software\TEST"
strValueName = "TestDWord"
oReg.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
Wscript.Echo "Current User: " & strvaluename & " - " & dwValue
'Get a string value
strKeyPath = "SOFTWARE\TEST"
strValueName = "TestString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Wscript.Echo "Local Machine: " & strvaluename & " - " & strvalue
 

Get file information and version

file = InputBox("Enter a file  to test with","File version","c:\myfile.txt")
if Trim(file) <> "" then
FileVersion(file)
end if
public sub FileVersion(strTarget)
' Make the target string format to sql query requirements
i = 0
for i = 1 to len(strTarget) step 1
if mid(strTarget,i,1) = "\" then
strTarget = mid(strTarget,1,i) & "\" & mid(strTarget,i+1)
i = i + 2
end if
next
strComputer = "."
strQuery="Select * from CIM_DataFile where Name = '" & strTarget & "'"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery(strQuery)
For Each objFile in colFiles
'wscript.echo objfile.getobjecttext_
strmsg=""
strmsg = strmsg & "File Name: " & vbTAB & objfile.name & vbCRLF
strmsg = strmsg & "File Type: " & vbTAB & objfile.filetype & vbCRLF
strmsg = strmsg & "File Size: " & vbTAB & vbTAB & objfile.filesize & vbCRLF
strmsg = strmsg & "File Version: " & vbTAB & objfile.version & vbCRLF
strmsg = strmsg & "Manufacturer: " & vbTAB & objfile.manufacturer & vbCRLF & vbCRLF
strmsg = strmsg & "Readable: " & vbTAB & objfile.readable & vbCRLF
strmsg = strmsg & "Writeable: " & vbTAB & objfile.writeable & vbCRLF
strmsg = strmsg & "Hidden: " & vbTAB & vbTAB & objfile.hidden & vbCRLF
strmsg = strmsg & "System: " & vbTAB & vbTAB & objfile.system & vbCRLF
strmsg = strmsg & "Archive: " & vbTAB & vbTAB & objfile.archive & vbCRLF
strmsg = strmsg & "Encrypted: " & vbTAB & objfile.encrypted & vbCRLF
strmsg = strmsg & "Compressed: " & vbTAB & objfile.compressed & vbCRLF & vbCRLF & vbCRLF
strmsg = strmsg & "Created:" & vbTAB & mid(objfile.CreationDate,5,2) & "/" &_
mid(objfile.CreationDate,7,2) & "/" & mid(objfile.CreationDate,1,4) & vbCRLF
strmsg = strmsg & "Installed:" & vbTAB & mid(objfile.InstallDate,5,2) & "/" &_
mid(objfile.InstallDate,7,2) & "/" & mid(objfile.InstallDate,1,4) & vbCRLF
strmsg = strmsg & "Last Accessed:" & vbTAB & mid(objfile.LastAccessed,5,2) & "/" &_
mid(objfile.LastAccessed,7,2) & "/" & mid(objfile.LastAccessed,1,4) & vbCRLF
strmsg = strmsg & "Last Modified:" & vbTAB & mid(objfile.LastModified,5,2) & "/" &_
mid(objfile.LastModified,7,2) & "/" & mid(objfile.LastModified,1,4) & vbCRLF
response = msgbox(strmsg, vbokonly + vbinformation, "ShowVersion Script")
Next
end sub
 

List local users

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Account Where LocalAccount = True")
For Each objItem in colItems

if objItem.SIDType = 1 THEN
Wscript.Echo "Status: " & objItem.GetObjectText_
end if
Next

Show IP information (similar to winipconfig)

on error resume next
strmsg = ""
strBlankMsg="No other interface cards configured"
index=0
set wmi = GetObject("winmgmts:root/CIMV2")
wql = "select * from Win32_NetworkAdapterConfiguration"
set result = wmi.ExecQuery(wql)
for each instance in result
if Not vartype(instance.IPAddress) = 1 then
strmsg = strmsg & "Description:" & vbTAB & instance.Description & vbCRLF & vbCRLF
strmsg = strmsg & "IP Address:" & vbTAB & instance.IPAddress(index) & vbCRLF
strmsg = strmsg & "Subnet Mask:" & vbTAB & instance.IPSubnet(index) & vbCRLF
strmsg = strmsg & "Gateway:" & vbTAB & vbTAB & instance.DefaultIPGateway(index) & vbCRLF & vbCRLF
strmsg = strmsg & "MAC Address:" & vbTAB & instance.MACAddress & vbCRLF & vbCRLF
strmsg = strmsg & "DNS Host Name:" & vbTAB & instance.DNSHostName & "." & instance.DNSDomain & vbCRLF
strmsg = strmsg & "DNS Domain:" & vbTAB & instance.DNSDomain & vbCRLF
strmsg = strmsg & "DHCP Enabled:" & vbTAB & instance.DHCPEnabled & vbCRLF
strmsg = strmsg & "DHCP Server:" & vbTAB & instance.DHCPServer & vbCRLF
strmsg = strmsg & "LeaseObtained:" & vbTAB & mid(instance.DHCPLeaseObtained,5,2) & "/" &_
mid(instance.DHCPLeaseObtained,7,2) & "/" & mid(instance.DHCPLeaseObtained,1,4) & vbCRLF
strmsg = strmsg & "LeaseExpires:" & vbTAB & mid(instance.DHCPLeaseExpires,5,2) & "/" &_
mid(instance.DHCPLeaseExpires,7,2) & "/" & mid(instance.DHCPLeaseExpires,1,4) & vbCRLF & vbCRLF
if instance.WINSPrimaryServer="127.0.0.0" then
strmsg = strmsg & "Primary WINS:" & vbTAB & "" & vbCRLF
else
strmsg = strmsg & "Primary WINS:" & vbTAB & instance.WINSPrimaryServer & vbCRLF
end if
if instance.WINSSecondaryServer="127.0.0.0" then
strmsg = strmsg & "Secondary WINS:" & vbTAB & "" & vbCRLF
else
strmsg = strmsg & "Secondary WINS:" & vbTAB & instance.WINSSecondaryServer & vbCRLF
end if
response = MsgBox(strmsg, vbOKOnly + vbInformation, "Michelin ISIS Computer - IP Configuration")
index = index + 1
strmsg = ""
else
if strBlankMsg="No other interface cards configured" then
strBlankMsg = "Other network interfaces detected but not configured for IP:" & vbCRLF & vbCRLF
strBlankMsg = strBlankMsg & vbTAB & instance.Description & vbCRLF & vbCRLF
else
strBlankMsg = strBlankMsg & vbTAB & instance.Description & vbCRLF & vbCRLF
end if
end if
next
response=MsgBox(strBlankMsg,vbOkOnly,"Other NICs")
 

Find a string in a text file

Const ForReading = 1
strComputer = "."
strfind = inputbox("What text do you want to find?", "Find text in document")
strfile = inputbox("What file do you want to look in?", "Find text in document")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strmsg=""
on error resume next
if objFSO.fileexists(strfile) then
Set objTextFile = objFSO.OpenTextFile(strFile, ForReading)
Do Until objTextFile.AtEndOfStream
strTextLine = objTextFile.Readline
stroffset=instr(1,strtextline,strfind,1)
if stroffset > 0 then
strmsg = strmsg & strtextline & vbcrlf
end if
Loop
objTextFile.Close
end if
if len(strmsg)>0 then
wscript.echo strmsg
else
wscript.echo "No match found"
end if
 

Show a environment variable

set shell = CreateObject("wscript.shell")
set sysEnv = shell.Environment("SYSTEM")
'set sysEnv = shell.Environment("USER")
' Show the current OS on an NT machine
env = SysEnv("OS")
msgbox env
' Create a enviroment variable
'SysEnv("testvar") = "test"
' Fetch the variable
'env = SysEnv("testvar")
'msgbox env
' Remove the variable
'SysEnv.Remove("testvar")
 

List the processes currently running

Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process")
For Each objProcess in colProcess
strList = strList & vbCr & objProcess.Name
Next
WSCript.Echo strList
Rate this page

Products

 

News

ID3 Editor 1.29.51 is now available. Added chapters and chapter table of contents. Fixed log file issues under Big Sur, Monterey and Ventura. Added a check for ANSI fields just in case Unicode is used.

QS Disclaimer 4.7.17 is now available. This version fixes an issue with Exchange 2019 and Windows 2019.

RTF to HTML converter 1.3.11 is now available. This version adds line spacing and raw output.

Disc Image Professional 2.3.1 is now available. This upgrade adds multi-user support and fixes a Vista mount issue.

MSAD Login 3.1.0 is now available. This version includes TLS and Kerberos support.

Archive SE 1.1.5 is now available. This upgrade adds support for Tar and BZip2.

back to top  


Facebook  Twitter  Google+ 


Copyright © 1990-2024 Pa-software. All Rights Reserved.
Developer of Exchange Server e-mail disclaimers, compression, ISO CD/DVD disc image management, MP3 ID3 editing and Macintosh Active Directory integration.