Sign in to follow this  
Followers 0
arcticpup

System Spec Script review

3 posts in this topic

#1 ·  Posted (edited)

Hi all,

As you know, I'm 99% novice at AutoIt, and thanks to your help, I've compiled a little app.

Is there anywhere I can post a script for some feedback? It's still a work in progress, but esentially works.....(Example scripts forum doesn't seem right for some reason?)

Apologies if this is not the right forum for such requests.

It's basically a tool to read some reg values, check some system specs and display icons as appropriately.

Many thanks

Iain

Edited by arcticpup

Share this post


Link to post
Share on other sites



Hey,

You can just include the code in your post, if someone wants to take a look at it and let you know they can drop a reply.

I dont think anyone would mind, if they do you will find out soon enough :D

Share this post


Link to post
Share on other sites

Hey,

You can just include the code in your post, if someone wants to take a look at it and let you know they can drop a reply.

I dont think anyone would mind, if they do you will find out soon enough :o

Here you go then! :D

Like I said, it is a system spec tool, with a bit of SQL thrown in (Although I can't get the SQL UDF to get @@version from SQL, so hence the OSQL bit......)

CODE
AutoItSetOption ( "TrayIconHide" , 1)

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_Res_Comment=A very quick system spec check

#AutoIt3Wrapper_Res_File_Add=C:\Documents and Settings\iain.broughton\My Documents\My Pictures\ad_logo.JPG,$pic ,$pic

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#include <_SQL.au3>

;Set variables

dim $line, $temp, $sqlinfo, $OS1, $OS2, $RAM, $HDD

dim $Mem, $dot, $mem2, $mem3, $free, $free1, $free1, $free3

dim $cpu, $master, $datasource, $mdac, $net, $server, $bkp, $bkp1, $bkp2

;~ @OSVersion

;~ Returns one of the following: "WIN_2008", "WIN_VISTA", "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95"

$string = @OSVersion

$string = StringReplace($string,"WIN_2008","Windows Server 2008 ("&@OSServicePack&")")

$string = StringReplace($string,"WIN_VISTA","Windows Vista ("&@OSServicePack&")")

$string = StringReplace($string,"WIN_2003","Windows Server 2003 ("&@OSServicePack&")")

$string = StringReplace($string,"WIN_XP","Windows XP ("&@OSServicePack&")")

$string = StringReplace($string,"WIN_2000","Windows 2000")

$string = StringReplace($string,"WIN_NT4","Windows NT 4. This operating system is not supported.")

$string = StringReplace($string,"WIN_ME","Windows Millenium Edition. This operating system is not supported.")

$string = StringReplace($string,"WIN_98","Windows 98. This operating system is not supported.")

$string = StringReplace($string,"WIN_95","Windows 95. This operating system is not supported.")

$RAM = 1022

$HDD = 10

$Mem = MemGetStats()

$dot=chr(149)

;Turn KB RAM into MB

$mem2 = $Mem[1] / 1024

;And round it for a nice display

$mem3 = Round($mem2, 0)

;Get free HDD space and round this too

$free = DriveSpaceFree("c:\")

$free1 = Round($free, 1)

$free2 = $free1 / 1024

$free3 = Round($free2, 1)

;Get processer architecture

$cpu=@ProcessorArch

;Read various registry keys

$master = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Apex Software\incTax\DataLocations", "MasterData")

$datasource = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Apex Software\incTax\DataLocations", "Data Source")

$mdac = RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\DataAccess", "FullInstallVer")

$net = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5", "Version")

;Trim the variable to be able to ping the server later on

$server = StringRegExpReplace($datasource, "\\.*", "", 0)

;We aint gonna support 64 bit!

If $cpu= "x64" then

MsgBox(64, "Warning", "64 bit operating systems are not supported")

Exit

EndIf

dim $SQLErr

$SQLErr=("Can not connect to SQL")

;SQL script to get version

Run(@ComSpec & " /c " & 'osql -S' & $datasource & ' -E -oSagetmp.txt -n' & @CR )

sleep (1000)

Send("select @@version" & @CR & "go" & @CR)

ProcessClose ( "OSQL.EXE")

sleep(1000)

;Get the time the last backup was taken

_SQLRegisterErrorHandler();register the error handler to prevent hard crash on COM error

$con = _SQLStartup()

If @error then Msgbox(0,"Error","Error starting ADODB.Connection")

_sqlConnect(-1,$datasource,"Master","sa","Adm1n")

$bkp = _SQLExecute(-1,"Use Master SELECT Value from MasterSettings where name = 'ZBkUpActionLatestBkUp:date'")

If Not @error then

$sbkp = _SqlGetDataAsString($bkp)

$bkp1 = StringTrimLeft($sbkp, 5)

$bkp2 =StringStripCR($bkp1)

_SQLClose()

Else

EndIf

;Read the temp file to get SQL version

#Include <File.au3>

$temp=("temp.txt")

$line=FileReadLine("Sagetemp.txt",11)

filedelete("temp.txt")

sleep(100)

$sqlinfo = StringRegExpReplace($line, "--.*", "", 0)

sleep(500)

#Region ### START Koda GUI section ### Form=c:\documents and settings\desktop\form1.kxf

;Create the form

$Form1_1 = GUICreate("System Check", 500,650, 100, 100)

GUISetBkColor(0xFFFFFF)

GUISetIcon("C:\Program Files\Fred.exe")

$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\My Documents\My Pictures\ad_logo.JPG", 24, 8, 468, 84, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))

;RAM check

If $mem3 > $RAM Then

$Icon1 = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -111, 16, 96, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP))

$Label1 = GUICtrlCreateLabel($mem3 & " Mb of RAM is installed", 64, 104, 180, 33)

Else

$Icon2 = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -110, 16, 96, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP))

$Label2 = GUICtrlCreateLabel($mem3 & " Mb of RAM is installed. This is not enough", 64, 104, 180, 33)

EndIf

;Free space check

If $free3 > $HDD Then

$Icon3= GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -111,16, 152, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP))

$Label3= GUICtrlCreateLabel($free3 & " Gb of free disk space is availible", 64, 152, 180, 33)

Else

$Icon4= GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -110, 24, 152, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP))

$Label4 = GUICtrlCreateLabel($free3 & " Gb of free disk space is availible. This is not enough", 64, 152, 180, 33)

EndIf

;Supported operating systems

If $string = "Windows XP (Service Pack 3)" then

$Label5 = GUICtrlCreateLabel($string & " is installed.", 64, 200, 280, 33)

$Icon6a = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -111, 16, 200, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

;$Label6 = GUICtrlCreateLabel("Supported systems are:-", 336, 104, 117, 17)

;$Label7 = GUICtrlCreateLabel("Windows XP Professional (SP3)", 336, 128, 154, 17)

;$Label8 = GUICtrlCreateLabel("Windows Vista (Business edition)(SP1)", 336, 152, 200, 170)

Else

$Label5b = GUICtrlCreateLabel($string & " is installed."& @CR & "Service Pack 3 is the minimum recommended", 64, 200, 280, 33)

$Icon6c = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -110, 16, 200, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

EndIf

;MDAC version

If $mdac < '2.8' Then

$Label9 = GUICtrlCreateLabel("MDAC Version is out of date" & @CR & "Installed version is " & $mdac, 64, 248, 267, 49)

$Icon5 = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -110, 16, 248, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

Else

$Label9a = GUICtrlCreateLabel("MDAC Version is " & $mdac, 64, 248, 267, 49)

$Icon5a = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -111, 16, 248, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

endif

;Check .NET version

if $net = "3.5.30729.01" then

$Icon6 = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -110, 16, 304, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

$Label11 = GUICtrlCreateLabel("Your .NET version is " & $net, 64, 368, 280, 41)

else

$Label11b = GUICtrlCreateLabel("Your .NET version is incorrect " & $net, 64, 368, 280, 41)

$Icon6 = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -110, 16, 304, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

endif

;Display SQL info

$Label10 = GUICtrlCreateLabel($sqlinfo, 64, 304, 269, 49)

$Icon6b = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -111, 16, 304, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

$Icon7 = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -110, 16, 368, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

;Get MSI version

$Label12 = GUICtrlCreateLabel("MSI version", 64, 424, 292, 49)

$Icon8 = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -111, 16, 424, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

;Last section for info only so no need to change icons.

$Label13 = GUICtrlCreateLabel("Your master data path is " & $master & @CR & "Your SQL Server is " & $datasource, 64, 488, 381, 149)

$Icon9 = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -111, 16, 488, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

;Ping the SQL server

$ping = Ping($server,250)

if $ping then

$Icon10 = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -111, 16,550, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

$Label14 = GUICtrlCreateLabel("Your server can be contacted (" & $server & ")", 64, 550, 381, 149)

else

$Icon10a = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -110, 16,550, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

$Label14a = GUICtrlCreateLabel("Your server can not be contacted (" & $server & ")", 64, 550, 381, 149)

EndIf

;When last backup was taken

$Icon15a = GUICtrlCreateIcon("C:\WINDOWS\system32\shell32.dll", -111, 16,600, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

$Label15a = GUICtrlCreateLabel("Last backup taken" & $bkp1, 64,600, 381, 149)

;Send temp SQL info file to recycler

FileRecycle("Sagetemp.txt")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0