Page 1 of 1 1
Topic Options
#48225 - 1999-09-28 09:22 AM Example script to retrieve information out of registry
Anonymous
Unregistered


Here follows an example of how to get a lot of information out of the registry. I've only done this for Win95/98 and for our company... maybe it's usefull for someone.

I have one problem ! I can't read out the RESOLUTION? Anyone who can help me???

Thnx,

:INFORMATION

USE N: "\\SEN-WEL-NT03\SEN-DATA-INF$"
REDIRECTOUTPUT("N:\" + ReadValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName") + ".TXT",1)

? "-----------------------------------------------------------------"
? "Computer information generated at : " + @DATE + " - " + @TIME
? " User logged on : " + @FULLNAME + " on " @DOMAIN
? "-----------------------------------------------------------------"
? ""
? "ProduktName : " + ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","ProductName")
? "Version : " + ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","VersionNumber")
? "Revision : " + LTRIM(ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SubVersionNumber"))
? "Plus! : " + ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","Plus! VersionNumber")
? "Internet Explorer : " + ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main","Wizard_Version")
? "Key : " + ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","ProductKey")
? "Organisation : " + ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","RegisteredOrganization")
? "Owner : " + ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","RegisteredOwner")
? "SystemRoot : " + ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SystemRoot")
? "Program Files : " + ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","ProgramFilesPath")
$ProgramFilesPath = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","ProgramFilesPath")
? ""
? "Office Version : " + ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Office8.0","DisplayName")
$OfficePath = ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Office\8.0\Common\InstallRoot","")
$OfficeVersion = GetFileVersion($OfficePath + "\Office\winword.exe", "FileVersion")
If $OfficeVersion = "8.0b"
? "Service Pack : SR-II"
Else
$OfficeVersion = GetFileVersion($OfficePath + "\Office\mso97.dll", "FileVersion")
If $OfficeVersion = "8.0.4202"
? "Service Pack : SR-I"
Else
? "Service Pack : Basic installation"
Endif
Endif
? "Office Path : " + ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Office\8.0\Common\InstallRoot","")
? ""

If ExistKey("HKEY_LOCAL_MACHINE\Software\Nico Mak Computing\WinZip") = 0
? "WinZip Version : " + ReadValue("HKEY_LOCAL_MACHINE\Software\Nico Mak Computing\WinZip\WinIni","win32_version")
? " Name : " + ReadValue("HKEY_LOCAL_MACHINE\Software\Nico Mak Computing\WinZip\WinIni","Name")
? " S/N : " + ReadValue("HKEY_LOCAL_MACHINE\Software\Nico Mak Computing\WinZip\WinIni","SN")
Else
If Exist($ProgramFilesPath + "\WinZip\WinZip32.exe")
? "Winzip Version : " + GetFileVersion($ProgramFilesPath + "\WinZip\winzip32.exe","ProductVersion")
Endif
Endif
? ""

IF EXIST("C:\LOTUS\CAMPLAY\SCPLAYER.EXE")
? "Lotus ScreenCam : Yes"
Else
? "Lotus ScreenCam : No"
Endif

? ""

If ExistKey("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Acrobat 4.0") = 0
? "Acrobat version : 4.0 "
? " path : " + ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Acrobat 4.0","InstallLocation")
Else
If ExistKey("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Acrobat Reader 3.01") = 0
? "Acrobat version : 3.01 "
Endif
Endif

? ""

If ExistKey("HKEY_LOCAL_MACHINE\Software\SAP\SAP Client\Version 45B") = 0
? "SAP version : 4.5B"
? "SAP Path : " + ReadValue("HKEY_LOCAL_MACHINE\Software\SAP\SAP Client\Version 45B\Settings","SapDestDir")
? "SAP WorkPath : " + ReadValue("HKEY_LOCAL_MACHINE\Software\SAP\SAP Client\Version 45B\Settings","SapWorkDir")
Else
If ExistKey("HKEY_LOCAL_MACHINE\SOFTWARE\SAP\RFC\Sapgui\3.0F") = 0
? "SAP version : 4.0B"
? "SAP Path : C:\SAPPC40B"
? "SAP WorkPath : C:\SAPWorkDir"
Endif
Endif

? ""
? "Screen Size : " + ReadValue("HKEY_CURRENT_CONFIG\Display\Settings","Resolution")
? "Bits per pixel : " + ReadValue("HKEY_CURRENT_CONFIG\Display\Settings","BitsPerPixel")
? "Screensaver active : " + ReadValue("HKEY_CURRENT_USER\Control Panel\Desktop","ScreenSaveActive")
? "Screensaver timeout: " + ReadValue("HKEY_CURRENT_USER\Control Panel\Desktop","ScreenSaveTimeOut")
? "Wallpaper : " + ReadValue("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper")
? ""

? "Processor : " + ReadValue("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0","Identifier")
? "Computer Name : " + ReadValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName")
? "IP Address : " + @IPADDRESS0
? "Domain : " + @DOMAIN
? "User language : " + @USERLANG
? "Disk Space C: : " + GetDiskSpace("C:\") + " KB"
? "Disk Space D: : " + GetDiskSpace("D:\") + " KB"
? ""

$INDEX=0
$Loop = "Y"
While $Loop = "Y"
$ValueName = ENUMVALUE("HKEY_USERS\.DEFAULT\Software\Microsoft\Internet Explorer\TypedURLs", $Index)
If @ERROR = 0
If $Index = 0
? "Typed URL's : " ReadValue("HKEY_USERS\.DEFAULT\Software\Microsoft\Internet Explorer\TypedURLs", $ValueName)
Else
? " : " ReadValue("HKEY_USERS\.DEFAULT\Software\Microsoft\Internet Explorer\TypedURLs", $ValueName)
Endif
$Index = $Index + 1
Else
$Loop = "N"
Endif
LOOP

$INDEX=0
$Loop = "Y"
While $Loop = "Y"
$ValueKey = ENUMKEY("HKEY_CURRENT_USER\Network\Persistent", $Index)
If @ERROR = 0
If $Index = 0
? "Network mappings : " + $ValueKey + " -> " ReadValue("HKEY_CURRENT_USER\Network\Persistent\" + $ValueKey, "RemotePath")
Else
? " : " + $ValueKey + " -> " ReadValue("HKEY_CURRENT_USER\Network\Persistent\" + $ValueKey, "RemotePath")
Endif
$Index = $Index + 1
Else
$Loop = "N"
Endif
LOOP

? ""
$INDEX=0
$Loop = "Y"
While $Loop = "Y"
$ValueKey = ENUMKEY("HKEY_CURRENT_USER\Network\Recent", $Index)
If @ERROR = 0
If $Index = 0
? "Recent mappings : " + $ValueKey
Else
? " : " + $ValueKey
Endif
$Index = $Index + 1
Else
$Loop = "N"
Endif
LOOP

? ""
$INDEX=0
$Loop = "Y"
While $Loop = "Y"
$ValueKey = ENUMKEY("HKEY_CURRENT_USER\RemoteAccess\Profile", $Index)
If @ERROR = 0
If $Index = 0
? "Remote access : " + $ValueKey
? " username -> " + ReadValue("HKEY_CURRENT_USER\RemoteAccess\Profile\" + $ValueKey, "User")
? " call-back nr -> " + ReadValue("HKEY_CURRENT_USER\RemoteAccess\Profile\" + $ValueKey, "Number")
Else
? " : " + $ValueKey
? " username -> " + ReadValue("HKEY_CURRENT_USER\RemoteAccess\Profile\" + $ValueKey, "User")
? " call-back nr -> " + ReadValue("HKEY_CURRENT_USER\RemoteAccess\Profile\" + $ValueKey, "Number")
Endif
$Index = $Index + 1
Else
$Loop = "N"
Endif
LOOP

? ""
$INDEX=0
$Loop = "Y"
While $Loop = "Y"
$ValueKey = ENUMVALUE("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", $Index)
If @ERROR = 0
If $Index = 0
? "Automatic startup : " + $ValueKey + " -> " + ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run",$ValueKey)
Else
? " : " + $ValueKey + " -> " + ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run",$ValueKey)
Endif
$Index = $Index + 1
Else
$Loop = "N"
Endif
LOOP

? ""
$INDEX=0
$Loop = "Y"
While $Loop = "Y"
$ValueKey = ENUMKEY("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers", $Index)
If @ERROR = 0
If $Index = 0
? "Installed printers : " + $ValueKey + " -> " + ReadValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers\" + $ValueKey, "Port")
Else
? " : " + $ValueKey + " -> " + ReadValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers\" + $ValueKey, "Port")
Endif
$Index = $Index + 1
Else
$Loop = "N"
Endif
LOOP

? ""

If $ProgramFilesPath <> ""
$ProgramFolders = Dir("C:\Program Files\*.")
? "Program Files contents : " + $ProgramFolders
While $ProgramFolders <> "" AND @ERROR = 0
? " : " + $ProgramFolders
Dir()
Loop
Endif

? ""
$StartMenuPath = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SystemRoot")
$StartMenuPath = $StartMenuPath + "\Start Menu\Programs\*."
If $StartMenuPath <> ""
$StartMenuPath = Dir($StartMenuPath)
? "Program menu contents : " + $StartMenuPath
While $StartMenuPath <> "" AND @ERROR = 0
? " : " + $StartMenuPath
Dir()
Loop
Endif




? "Security settings"
? "-----------------"
? ""
? " NoDevMgrPage : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\System","NoDevMgrPage")
? " NoDispCPL : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\System","NoDispCPL")
? " NoSecCPL : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\System","NoSecCPL")
? " NoNetSetup : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Network","NoNetSetup")
? " NoEntireNetwork : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Network","NoEntireNetwork")
? " NoWorkGroupContents : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Network","NoWorkGroupContents")
? " WinOldApp : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\WinOldApp","Disabled")
? " NoRealMode : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\WinOldApp","NoRealMode")
? " NoAddPrinter : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoAddPrinter")
? " NoDeletePrinter : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoDeletePrinter")
? " NoDesktop : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoDesktop")
? " NoFind : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoFind")
? " NoNetHood : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoNethood")
? " NoSetFolders : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoSetFolders")
? " NoSetTaskBar : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoSetTaskbar")
? " NoSaveSettings : " + ReadValue("HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoSaveSettings")

? " MustBeValidated : " + ReadValue("HKEY_LOCAL_MACHINE\Network\Logon","MustBeValidated")
? " NoDomainPwdCaching : " + ReadValue("HKEY_LOCAL_MACHINE\Network\Logon","NoDomainPwdCaching")
? ""
? "-----------------------------------------------------------------"

USE N: /DELETE /PERSISTENT
RETURN

Top
#48226 - 1999-09-30 05:51 AM Re: Example script to retrieve information out of registry
PaulMoxey Offline
Getting the hang of it

Registered: 1999-07-22
Posts: 90
Loc: Villawood, NSW, Australia
That is truly excellent (and very handy) script:

Here's the fix for your resolution problem (and also BPP):

quote:

? "Screen Size : " + ReadValue("HKEY_LOCAL_MACHINE\Config\0001\Display\Settings","Resolution")
? "Bits per pixel : " + ReadValue("HKEY_LOCAL_MACHINE\Config\0001\Display\Settings","BitsPerPixel")

Hope that helps......

_________________________
Paul Moxey POS & Senior Network Administrator BarloworldCoatings (AUST) Pty Ltd

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.095 seconds in which 0.073 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org