Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: NT assessment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; File: AssessNet.wbt ; Input Parameters: None ; ; Dominique Piot - March 21st 1999 ; Modifications: ; 4/8/1999 - DP - GetUserInfo ; Instead of checking if P drive exist by using UserHasPDrive = DiskExist("P:") ; check the environment variable HomeDrive. Users may have mapped a P drive ; temporarely. ; 4/8/1999 - DP - MoveToDirectory ; Include RecordType in the log when access is denied ; 2/8/2000 - DP - Simplify get IP information ; - Do not connect to a Netresource. ; Improvements: ; 2/18/2000 - Reset Item value in module Display Info. ; 2/25/2000 1.1 - Indicate server name for each Network Drives ; 1.2 - Check version stored on NetResource ; - Store files on NetResource ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Record Written: ; 0 Wksname, @Tab, WksSite, @Tab, WksBuilding, @Tab, WksFloor, @Tab, WksAisle, @Tab, UserFirstName, @Tab, UserLastName, @Tab, UserId, @Tab, IsStandalone ; 1 Wksname, @Tab, memory, @Tab, Csize, @TAB, Cavail ; 2 Wksname, @Tab, majorver, ".", minorver, " ", CSD, @Tab, windir, @TAB, sysdir ; 3 Wksname, @Tab, Username, @Tab, LogonDomain, @Tab, UserIsAdmin, @Tab, Lgroups, @Tab, LogonServer ; 4 Wksname, @Tab, LocalUsers ; 5 Wksname, @Tab, LocalAdmins ; 6 Wksname, @Tab, BrandName, @Tab, IsLaptop, @Tab, Processor, @Tab, CPU (Mhz), @Tab, CPU (Vendor) ; 7 Wksname, @Tab, HostName, @Tab, EthernetAdapter, @Tab, PhysicalAddress, @Tab, DHCPEnabled ; 8 Wksname, @Tab, IPAddress, @Tab, DNS1, @Tab, DNS2, @Tab, SubnetMask, @Tab, DefaultGateway, @Tab, PrimaryWins, @tab, SecondaryWins ; 9 Wksname, @Tab, FileName1, @Tab, FProductName, @Tab, FProductVersion, @Tab, FCompany ;10 Wksname, @Tab, Count, @Tab, List of Printers (server) ;11 Wksname, @Tab, List of printers available. ;12 Wksname, @Tab, List of people who have an account on the machine. ;13 Wksname, @Tab, List of installed Network. ;14 Wksname, @Tab, Count, @Tab, List of Floppy Drives. ;15 Wksname, @Tab, Count, @Tab, List of Hard Drives. ;16 Wksname, @Tab, Count, @Tab, List of (Network drive, @tab, ServerName). ;17 Wksname, @Tab, Count, @Tab, List of CD Rom. ;99 Wksname, @Tab, Debug Message ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AddExtender("WWWNT32I.DLL") AddExtender("WWPRT32I.DLL") Tempo = 5 AssessVersion = "1.2" Caption = StrCat ("AssessNet - version ", AssessVersion) VersionFile = "Version.dat" NetResource = "\\kp-is-s03\assessments" UserName = Environment ("UserName") WksName = Environment ("ComputerName") HomeDrive = Environment ("HomeDrive") TimeReadable = TimeDate () LogonDomain = "N/A" LogonServer = "N/A" LGroups = "N/A" UserIsAdmin = "N/A" LocalUsers = "N/A" LocalAdmins = "N/A" UserFirstName = "N/A" UserLastName = "N/A" UserHasPDrive = "N/A" WksSite = "N/A" WksBuilding = "N/A" WksFloor = "N/A" WksAisle = "N/A" WksOrg = "N/A" HostName = "N/A" DNS1 = "N/A" DNS2 = "N/A" EthernetAdapter= "N/A" PhysicalAddress= "N/A" DHCPEnabled = "N/A" IPAddress = "N/A" SubnetMask = "N/A" DefaultGateway = "N/A" PrimaryWins = "N/A" SecondaryWins = "N/A" ; ; Check if environment variables are set. ; If UserName == "" Message (Caption, "The variable UserName is not set. Program can't be run at this time.") Exit EndIf If WksName == "" Message (Caption, "The variable ComputerName is not set. Program can't be run at this time.") Exit EndIf ; ; Check if Standalone or networked. ; FileName = StrCat (NetResource, "/", VersionFile) ErrorMode(@OFF) Handle = FileOpen (FileName, "Read") ErrorMode(@CANCEL) If LastError() == 1077 ;Open error (no access...) IsStandalone = @True NetResource = DirGet () Else IsStandalone = @False CurrVersion = FileRead(Handle) FileClose(Handle) If AssessVersion != CurrVersion ErrorTxt = StrCat ("There is an updated version of this program", @CRLF) ErrorTxt = StrCat (ErrorTxt, "available in ", NetResource, @CRLF) ErrorTxt = StrCat (ErrorTxt, "It is recommended to use this updated version.", @CRLF) Message (Caption, ErrorTxt) GoTo Cancel EndIf End If LogFile = StrCat (NetResource, "/", WksName, ".txt") ; :IsItRunning Sounds(0) AlreadyOpen = WinExist(Caption) if AlreadyOpen == @TRUE then goto Cancel ; CheckForKey = IsKeyDown(@SHIFT) if CheckForKey == @YES q = AskYesNo(Caption, "Do you want to display the data ?") If q == @YES Then gosub DisplayInfo Exit endif ; ; Open Log File. ; If FileExist(LogFile) fh = FileOpen(logfile, "Append") Else fh = FileOpen(logfile, "Write") EndIf RecordType = 99 Log = StrCat (RecordType, @Tab, Wksname, @Tab, "Assess started") FileWrite(fh, log) ; ; Now Get user information. ; Gosub GetUserInfo RecordType = 0 Log = StrCat (RecordType, @Tab, Wksname, @Tab, WksSite, @Tab) Log = StrCat (Log, WksBuilding, @Tab, WksFloor, @Tab, WksAisle, @Tab) Log = StrCat (Log, UserFirstName, @Tab, UserLastName, @Tab, UserName, @Tab, IsStandalone) FileWrite(fh, log) ; ; Get Information ; gosub GetSystemInfo If IsStandalone == @False Then GoSub GetTCPInfo gosub GetPrinterInfo gosub GetShortcut :ExitProgram FileClose(fh) q = AskYesNo(Caption, "Data collection completed. Do you want to display the data ?") If q == @YES Then gosub DisplayInfo exit :Cancel exit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; :GetShortcut ProfilesList = DirItemize ("C:\Winnt\Profiles\*.*") ProfilesCount = ItemCount(ProfilesList, @tab) ; ; Record all users account informations. ; PeopleList = ProfilesList i = ItemLocate ("Administrator", PeopleList, @Tab) If i != 0 PeopleList = ItemRemove (i, PeopleList, @Tab) EndIf i = ItemLocate ("All Users", PeopleList, @Tab) If i != 0 PeopleList = ItemRemove (i, PeopleList, @Tab) EndIf i = ItemLocate ("Default User", PeopleList, @Tab) If i != 0 PeopleList = ItemRemove (i, PeopleList, @Tab) EndIf RecordType = 12 Log = StrCat (RecordType, @Tab, Wksname, @Tab) Log = StrCat (Log, PeopleList) FileWrite(fh, log) AppList = "" For i0 = 1 To ProfilesCount Profile = ItemExtract(i0, ProfilesList, @tab) If UserIsAdmin == @True Then GoTo Process If Profile == "Administrator" Then GoTo Process If Profile == "All Users" Then GoTo Process If Profile == "Default User" Then GoTo Process If (StrLower(Profile) != StrLower(Username)) Then GoTo NoProcess :Process MessageTxt = StrCat ("Working on ", Profile) Display (Tempo, Caption, MessageTxt) ; ; Get the link files from Desktop. ; Directory = StrCat ("C:\Winnt\Profiles\", Profile, "\Desktop") Gosub MoveToDirectory FileNameList = FileItemize("*.LNK") FileTot = ItemCount(FileNameList, @tab) For i = 1 To FileTot FileName = ItemExtract(i, FileNameList, @tab) FileName1 = StrFix(FileName, "", Strlen(FileName) - 4) ;Remove the ".lnk" InfoLnk = ShortcutInfo(FileName) target = StrUpper (ItemExtract(1, InfoLnk, @tab)) Path = FilePath (target) Root = FileRoot(target) Extension = FileExtension (target) If StrLower(extension) == "exe" index = ItemLocate(FileName1, AppList, @Tab) If index == 0 AppList = ItemInsert(FileName1, -1, AppList, @Tab) FileN = FileLocate(target) ErrorMode(@OFF) FCompany = FileVerInfo(FileN, "", "CompanyName") FProductName = FileVerInfo(FileN, "", "ProductName") FProductVersion = FileVerInfo(FileN, "", "ProductVersion") ErrorMode(@Cancel) RecordType = 9 Log = StrCat (RecordType, @Tab, Wksname, @Tab, FileName1, @Tab) Log = StrCat (Log, FProductName, @Tab, FProductVersion, @Tab, FCompany) FileWrite(fh, log) EndIf End If Next i ; ; Get the link files from Start Menu. ; Directory = StrCat ("C:\Winnt\Profiles\", Profile, "\Start Menu") Gosub MoveToDirectory FileNameList = FileItemize("*.LNK") FileTot = ItemCount(FileNameList, @tab) For i = 1 To FileTot FileName = ItemExtract(i, FileNameList, @tab) FileName1 = StrFix(FileName, "", Strlen(FileName) - 4) ;Remove the ".lnk" InfoLnk = ShortcutInfo(FileName) target = StrUpper (ItemExtract(1, InfoLnk, @tab)) Path = FilePath (target) Root = FileRoot(target) Extension = FileExtension (target) If StrLower(extension) == "exe" index = ItemLocate(FileName1, AppList, @Tab) If index == 0 AppList = ItemInsert(FileName1, -1, AppList, @Tab) FileN = FileLocate(target) ErrorMode(@OFF) FCompany = FileVerInfo(FileN, "", "CompanyName") FProductName = FileVerInfo(FileN, "", "ProductName") FProductVersion = FileVerInfo(FileN, "", "ProductVersion") ErrorMode(@Cancel) RecordType = 9 Log = StrCat (RecordType, @Tab, Wksname, @Tab, FileName1, @Tab) Log = StrCat (Log, FProductName, @Tab, FProductVersion, @Tab, FCompany) FileWrite(fh, log) EndIf End If Next i sub1 = DirItemize("*.*") totdir = 0 level = 1 dir1 = DirGet() numdir1 = ItemCount(sub1, @tab) index1 = 0 :dsloop If index%level% == numdir%level% Then Goto upalevel index%level% = index%level% + 1 Directory = StrCat(dir%level%, ItemExtract(index%level%, sub%level%, @tab)) Gosub MoveToDirectory totdir = totdir+1 FileNameList = FileItemize("*.LNK") FileTot = ItemCount(FileNameList, @tab) For i = 1 To FileTot FileName = ItemExtract(i, FileNameList, @tab) FileName1 = StrFix(FileName, "", Strlen(FileName) - 4) ;Remove the ".lnk" InfoLnk = ShortcutInfo(FileName) target = StrUpper (ItemExtract(1, InfoLnk, @tab)) Path = FilePath (target) Root = FileRoot(target) Extension = FileExtension (target) If StrLower(extension) == "exe" index = ItemLocate(FileName1, AppList, @Tab) If index == 0 AppList = ItemInsert(FileName1, -1, AppList, @Tab) FileN = FileLocate(target) ErrorMode(@OFF) FCompany = FileVerInfo(FileN, "", "CompanyName") FVersion = FileVerInfo(FileN, "", "FileVersion") FInternalName = FileVerInfo(FileN, "", "InternalName") FOriginalFilename = FileVerInfo(FileN, "", "OriginalFilename") FProductName = FileVerInfo(FileN, "", "ProductName") FProductVersion = FileVerInfo(FileN, "", "ProductVersion") ErrorMode(@Cancel) RecordType = 9 Log = StrCat (RecordType, @Tab, Wksname, @Tab, FileName1, @Tab) Log = StrCat (Log, FProductName, @Tab, FProductVersion, @Tab, FCompany) FileWrite(fh, log) EndIf End If Next i level = level + 1 dir%level% = DirGet() sub%level% = DirItemize("*.*") numdir%level% = ItemCount(sub%level%, @tab) index%level% = 0 goto dsloop :upalevel drop(dir%level%,sub%level%,index%level%,numdir%level%) level = level-1 if level!=0 then goto dsloop :Noprocess next i0 :EndGetShortcut return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; :MoveToDirectory ;Needed to prevent WB(user) to go where not allowed to. ErrorMode(@OFF) users = wntAccessList("", Directory, "300", 1) ErrorMode(@CANCEL) Tmp = LastError() RecordType = 99 Log = StrCat (RecordType, @Tab, Wksname, @tab, "Access List for:", @Tab, Directory, @Tab, Users) FileWrite(fh, log) If Tmp > 499 ;530 = Access Denied. RecordType = 99 Log = StrCat (RecordType, @Tab, Wksname, @tab, "Access Denied on:", @Tab, Directory) FileWrite(fh, log) Else If users == "" RecordType = 99 Log = StrCat (RecordType, @Tab, Wksname, @tab, "Users access list empty for ", Directory) FileWrite(fh, log) Else DirChange(Directory) endif Endif :EndMoveToDirectory return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; :GetSysteminfo Display (Tempo, Caption, "Getting System Information. Please be patient...") minorver = WinVersion(@MINOR) ; Get Major version. majorver = WinVersion(@MAJOR) ; Get Minor version. memory = WinResources(11)/1024 ; Get Physical memory avail windir = DirWindows(0) ; Get Windows Directory sysdir = DirWindows(1) ; Get System Directory windir = StrUpper (windir) sysdir = StrUpper (sysdir) ; UserIsAdmin = @False LogonDomain = "N/A" LogonServer = "N/A" LGroups = "N/A" LocalUsers = "N/A" LocalAdmins = "N/A" If IsStandalone == @True Then GoTo SkipUserInfo ; ; Get information about groups structure & ; Determine if user is an administrator. ; Display (Tempo, Caption, "Getting Local Groups Information.") LogonDomain = wntUserInfo(1) LogonServer = wntUserInfo(3) UserUNC = StrCat (LogonDomain, "\", Username) ; RecordType = 99 Log = StrCat (RecordType, @Tab, Wksname, @tab, "User UNC is: ", UserUNC) FileWrite(fh, log) ; LGroups = wntMemberGrps("", UserUNC, @localgroup, 0) Pos = StrIndex(LGroups, "Administrators", 1, @FWDSCAN) If Pos == 0 UserIsAdmin = @False Else UserIsAdmin = @True EndIF LocalUsers = wntMemberList("","Users",@LOCALGROUP) LocalAdmins = wntMemberList("","Administrators",@LOCALGROUP) ; :SkipUserInfo Key = "Software\Microsoft\Windows NT\CurrentVersion" CSD = "" CBN = "" RegExist = RegExistValue(@REGMACHINE,StrCat (Key, "[CSDVersion]")) If RegExist regkey = RegOpenKey(@REGMACHINE, Key) CSD = RegQueryValue(regkey, "[CSDVersion]") CSD = StrUpper (CSD) RegCloseKey(regkey) Else CSD = "" EndIf RegExist = RegExistValue(@REGMACHINE,StrCat (Key, "[CurrentBuildNumber]")) If RegExist regkey = RegOpenKey(@REGMACHINE, Key) CBN = RegQueryValue(regkey, "[CurrentBuildNumber]") CBN = StrUpper (CBN) RegCloseKey(regkey) Else CBN = "" EndIf Csize = Int (DiskSize("C")/1048576) Cavail = Int (DiskFree("C")/1048576) ; CpuMhzKey="HARDWARE\DESCRIPTION\System\CentralProcessor\0[~MHz]" RegExist = RegExistValue(@REGMACHINE, CpuMhzKey) If RegExist CpuMhz=RegQueryValue(@REGMACHINE, CpuMhzKey) Else CpuMhz = "N/A" EndIf CpuIdentKey="HARDWARE\DESCRIPTION\System\CentralProcessor\0[Identifier]" RegExist = RegExistValue(@REGMACHINE,CpuIdentKey) If RegExist CpuIdent=RegQueryValue(@REGMACHINE,CpuIdentKey) Else CpuIdent = "N/A" EndIf CpuVendorKey="HARDWARE\DESCRIPTION\System\CentralProcessor\0[VendorIdentifier]" RegExist = RegExistValue(@REGMACHINE,CpuVendorKey) If RegExist CpuVendor=RegQueryValue(@REGMACHINE,CpuVendorKey) Else CpuVendor = "N/A" EndIf ; sysinfo = WinSysInfo( ) ProcessorType = ItemExtract(6, sysinfo, @TAB) ; InstalledNetworks = NetInfo(1) ; ; ; initialize PCMIA key to check Laptop / Desktop ; PCMCIAKey ="System\CurrentControlSet\Services\PCMCIA" RegExist = RegExistValue(@REGMACHINE,PCMCIAKey) If RegExist LapCheck=RegOpenKey(@REGMACHINE,PCMCIAKey) LapCheckList=RegQueryKeys(LapCheck) RegCloseKey(LapCheck) ;count number of subkeys of PCMIA key; if 0 then NOT a laptop LapCheckListCnt=ItemCount(LapCheckList,@TAB) If LapCheckListCnt!=0 IsLaptop = @True Else IsLaptop = @False EndIf Else IsLaptop = @False EndIf Display (Tempo, Caption, "Writing System Information.") ; ; Record Workstation h/w information. ; RecordType = 1 Log = StrCat (RecordType, @Tab, Wksname, @Tab) Log = StrCat (Log, memory, @Tab, Csize, @TAB, Cavail) FileWrite(fh, log) ; ; Record Workstation general NT information. ; RecordType = 2 Log = StrCat (RecordType, @Tab, Wksname, @Tab) Log = StrCat (Log, majorver, ".", minorver, " ", CSD, @Tab) Log = StrCat (Log, windir, @TAB, sysdir) FileWrite(fh, log) ; ; Record User informations. ; RecordType = 3 Log = StrCat (RecordType, @Tab, Wksname, @Tab) Log = StrCat (Log, Username, @Tab, LogonDomain, @Tab, UserIsAdmin, @Tab) Log = StrCat (Log, Lgroups, @Tab, LogonServer) FileWrite(fh, log) ; ; Record Workstation Architecture NT information. ; RecordType = 4 Log = StrCat (RecordType, @Tab, Wksname, @Tab) Log = StrCat (Log, LocalUsers) FileWrite(fh, log) ; ; Record Workstation Architecture NT information. ; RecordType = 5 Log = StrCat (RecordType, @Tab, Wksname, @Tab) Log = StrCat (Log, LocalAdmins) FileWrite(fh, log) ; ; Record CPU characteristics. ; RecordType = 6 Log = StrCat (RecordType, @Tab, Wksname, @Tab, BrandList, @Tab, IsLaptop, @Tab) Log = StrCat (Log, ProcessorType, @Tab, CpuMhz, @Tab, CPUVendor) FileWrite(fh, log) ; ; Installed Networks. ; RecordType = 13 Log = StrCat (RecordType, @Tab, Wksname, @Tab, InstalledNetworks) FileWrite(fh, log) ; ; FloppyDrives. ; ErrorMode(@OFF) FloppyDrives= DiskScan(1) ErrorMode(@CANCEL) Tmp = LastError() If Tmp > 499 FloppyDrives = "N/A" RecordType = 99 Log = StrCat (RecordType, @Tab, Wksname, "Error in DiskScan for floppy drive :", Tmp) FileWrite(fh, log) EndIf nb = ItemCount(FloppyDrives, @TAB) RecordType = 14 Log = StrCat (RecordType, @Tab, Wksname, @Tab, nb, @Tab, FloppyDrives) FileWrite(fh, log) ; ; HardDrives. ; ErrorMode(@OFF) HardDrives= DiskScan(2) ErrorMode(@CANCEL) Tmp = LastError() If Tmp > 499 HardDrives = "N/A" RecordType = 99 Log = StrCat (RecordType, @Tab, Wksname, "Error in DiskScan for hard drive:", Tmp) FileWrite(fh, log) EndIf nb = ItemCount(HardDrives, @TAB) RecordType = 15 Log = StrCat (RecordType, @Tab, Wksname, @Tab, nb, @Tab, HardDrives) FileWrite(fh, log) ; ; NetworkDrives. ; ErrorMode(@OFF) NetworkDrives= DiskScan(4) ErrorMode(@CANCEL) Tmp = LastError() If Tmp > 499 NetworkDrives = "N/A" RecordType = 99 Log = StrCat (RecordType, @Tab, Wksname, "Error in DiskScan for network drive:", Tmp) FileWrite(fh, log) EndIf nb = ItemCount(NetworkDrives, @TAB) RecordType = 16 Log = StrCat (RecordType, @Tab, Wksname, @Tab, nb) If nb > 0 Then For i = 1 to nb DriveLetter = ItemExtract (i, NetworkDrives, @Tab) NetRsrc = wntGetCon(DriveLetter) Log = StrCat (Log, @Tab, DriveLetter, @Tab, NetRsrc) next End If FileWrite(fh, log) ; ; CDRomDrives. ; ErrorMode(@OFF) CDRomDrives = DiskScan(8) ErrorMode(@CANCEL) Tmp = LastError() If Tmp > 499 NetworkDrives = "N/A" RecordType = 99 Log = StrCat (RecordType, @Tab, Wksname, "Error in DiskScan for CD Rom drive:", Tmp) FileWrite(fh, log) EndIf nb = ItemCount(CDRomDrives, @TAB) RecordType = 17 Log = StrCat (RecordType, @Tab, Wksname, @Tab, nb, @Tab, CDRomDrives) FileWrite(fh, log) :EndGetSysteminfo return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; :GetTCPinfo Display (Tempo, Caption, "Get TCP/IP Information. Please, be patient (bis...)") origdir = DirGet( ) OutputFile = StrCat (OrigDir, "IPCONFIG.TXT") RunHideWait(Environment("COMSPEC"), "/c IPCONFIG/ALL > %OutputFile%") If !FileExist(OutputFile) MessageTxt = StrCat ("TCP/IP parameters can't be determined.", @CRLF) MessageTxt = StrCat (MessageTxt, @CRLF, "No data will be captured.", @CRLF) Message (Caption, MessageTxt) GoTo ExitProgram EndIf ; handle = FileOpen (OutputFile, "Read") ; ; Get Host Name. ; Line = FileRead (handle) Line1 = "Host Name . . . . . . . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile HostName = StrSub (Line, Pos+StrLen (Line1), -1) ; ; Get DNS1. ; Line = FileRead (handle) Line1 = "DNS Servers . . . . . . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile DNS1 = StrSub (Line, Pos+StrLen (Line1), -1) ; ; Get DNS2 (if nothing but an IP address in the next line, this is it.) ; Line = FileRead (handle) Pos = StrIndex (Line, ":", 1, @FWDSCAN) If Pos == 0 ; Now find where it starts actually by skipping whatever is not an integer... Pos = 1 ch = StrSub (Line, Pos, 1) While IsInt (ch) == @FALSE If Pos == StrLen (Line) then GoTo EndGetTcpInfo Pos = Pos+1 ch = StrSub (Line, Pos, 1) EndWhile DNS2 = StrSub (Line, Pos, -1) Line = FileRead (handle) EndIf ; ; Skip lines until finding "Ethernet adapter" string. ; If Line == "*EOF*" then GoTo EndGetTcpInfo Pos1 = StrIndex(Line, "Ethernet adapter", 1, @FWDSCAN) While Pos1 == 0 Line = FileRead (handle) Pos1 = StrIndex(Line, "Ethernet adapter", 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile ; ; Get Description of Ethernet Adapter ; Line = FileRead (handle) If Line == "*EOF*" then GoTo EndGetTcpInfo Line1 = "Description . . . . . . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile EthernetAdapter = StrSub (Line, Pos+StrLen (Line1), -1) ; ; Get Physical Address ; Line = FileRead (handle) If Line == "*EOF*" then GoTo EndGetTcpInfo Line1 = "Physical Address. . . . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile PhysicalAddress = StrSub (Line, Pos+StrLen (Line1), -1) ; ; Get DHCP ; Line = FileRead (handle) If Line == "*EOF*" then GoTo EndGetTcpInfo Line1 = "DHCP Enabled. . . . . . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile DHCPEnabled = StrSub (Line, Pos+StrLen (Line1), -1) ; ; Get IP Address ; Line = FileRead (handle) If Line == "*EOF*" then GoTo EndGetTcpInfo Line1 = "IP Address. . . . . . . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile IPAddress = StrSub (Line, Pos+StrLen (Line1), -1) ; ; Get Subnet ; Line = FileRead (handle) If Line == "*EOF*" then GoTo EndGetTcpInfo Line1 = "Subnet Mask . . . . . . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile SubnetMask = StrSub (Line, Pos+StrLen (Line1), -1) ; ; Get Default Gateway ; Line = FileRead (handle) If Line == "*EOF*" then GoTo EndGetTcpInfo Line1 = "Default Gateway . . . . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile DefaultGateway = StrSub (Line, Pos+StrLen (Line1), -1) ; ; Get Wins 1 ; Line = FileRead (handle) If Line == "*EOF*" then GoTo EndGetTcpInfo Line1 = "Primary WINS Server . . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile PrimaryWins = StrSub (Line, Pos+StrLen (Line1), -1) ; ; Get Wins 2 ; Line = FileRead (handle) ;Get SecondaryWins If Line == "*EOF*" then GoTo EndGetTcpInfo Line1 = "Secondary WINS Server . . . : " Pos = StrIndex(Line, Line1, 1, @FWDSCAN) While Pos == 0 Line = FileRead (handle) Pos = StrIndex(Line, Line1, 1, @FWDSCAN) If Line == "*EOF*" then GoTo EndGetTcpInfo EndWhile SecondaryWins = StrSub (Line, Pos+StrLen (Line1), -1) :EndGetTCPinfo FileClose (handle) FileDelete (Outputfile) ; ; Record Workstation TCP/IP information. ; RecordType = 7 Log = StrCat (RecordType, @Tab, Wksname, @Tab) Log = StrCat (Log, HostName, @Tab, EthernetAdapter, @Tab, PhysicalAddress, @Tab, DHCPEnabled) FileWrite(fh, log) RecordType = 8 Log = StrCat (RecordType, @Tab, Wksname, @Tab) Log = StrCat (Log, IPAddress, @Tab, DNS1, @Tab, DNS2, @Tab) Log = StrCat (Log, SubnetMask, @Tab, DefaultGateway, @Tab, PrimaryWins, @tab, SecondaryWins) FileWrite(fh, log) return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; :GetUserInfo ; String1 = "Main User Information" String2 = "Workstation: %WksName%" String3 = "Please, fill the above and click OK. Then wait until" String4 = "program ends (30 sec roughly). Thanks you." ; SiteList = StrCat ("KO", @TAB, "KP", @TAB, "KRL", @TAB, "EL", @TAB, "MEC", @TAB, "Other") WksSite = SiteList FloorList = "" FOR i = 1 TO 10 T = ItemInsert (i, -1, FloorList, @TAB) FloorList = T Next WksFloor = FloorList BrandList = StrCat ("HP", @TAB, "IBM", @TAB, "Toshiba", @TAB, "Other") OrgList = StrCat ("APR", @Tab) OrgList = StrCat (OrgList, "EAMER", @Tab) OrgList = StrCat (OrgList, "JR", @Tab) OrgList = StrCat (OrgList, "LAR", @Tab) OrgList = StrCat (OrgList, "US&C (KO)", @Tab) OrgList = StrCat (OrgList, "US&C (KP)", @Tab) OrgList = StrCat (OrgList, "US&C (Other)", @Tab) OrgList = StrCat (OrgList, "Greater Asia", @Tab) ; OrgList = StrCat (OrgList, " ===================", @Tab) OrgList = StrCat (OrgList, "Other") WksOrg = OrgList ; ; Check if user has a P drive mounted. ; If HomeDrive == "P:" UserHasPDrive = @True Else UserHasPDrive = @False EndIf ; UserHasPDrive = DiskExist("P:") ; DPFormat = 'WWWDLGED,4.0' DPCaption = Caption DPX = 80 DPY = 40 DPWidth = 150 DPHeight = 150 DPNumControls = 20 DP01 = ' 45, 2, 120, DEFAULT, STATICTEXT, DEFAULT, "%String1%" ' DP02 = ' 5, 7, 30, DEFAULT, STATICTEXT, DEFAULT, "First Name" ' DP03 = ' 5, 15, 50, DEFAULT, EDITBOX, UserFirstName, "" ' DP04 = '110, 7, 30, DEFAULT, STATICTEXT, DEFAULT, "Last Name" ' DP05 = ' 90, 15, 50, DEFAULT, EDITBOX, UserLastName, "" ' DP06 = ' 25, 35, 120, DEFAULT, STATICTEXT, DEFAULT, "%String2%" ' DP07 = ' 5, 50, 50, DEFAULT, ITEMBOX, BrandList, BrandDef ' DP08 = ' 15, 77, 30, DEFAULT, STATICTEXT, DEFAULT, "Site" ' DP09 = ' 5, 85, 30, DEFAULT, ITEMBOX, WksSite, WksSiteDef ' DP10 = ' 50, 77, 30, DEFAULT, STATICTEXT, DEFAULT, "Bldg" ' DP11 = ' 40, 85, 30, DEFAULT, EDITBOX, WksBuilding, WksBuildingDef ' DP12 = ' 78, 77, 30, DEFAULT, STATICTEXT, DEFAULT, "Floor" ' DP13 = ' 75, 85, 20, DEFAULT, ITEMBOX, WksFloor, WksFloorDef ' DP14 = '110, 77, 30, DEFAULT, STATICTEXT, DEFAULT, "Aisle (if any)" ' DP15 = '100, 85, 45, DEFAULT, EDITBOX, WksAisle, WksAisleDef ' DP16 = ' 5, 130, 30, DEFAULT, PUSHBUTTON, DEFAULT, "OK", 1' DP17 = ' 45, 130, 30, DEFAULT, PUSHBUTTON, DEFAULT, "HELP", 2' DP18 = ' 85, 130, 30, DEFAULT, PUSHBUTTON, DEFAULT, "CANCEL", 0' DP19 = ' 5, 112, 130, DEFAULT, STATICTEXT, DEFAULT, "%String3%" ' DP20 = ' 5, 118, 130, DEFAULT, STATICTEXT, DEFAULT, "%String4%" ' retval = Dialog ("DP") ;HELP If retval == 2 Display (Tempo, Caption, "This is straighforward....No help needed !") Goto GetUserInfo End if :Cancel :EndGetUserInfo Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; :GetPrinterInfo Display (Tempo, Caption, "Get Printer Information. Almost done...") PrinterList = pGetPrtList(1) PrinterCount = ItemCount (PrinterList, @Tab) RecordType = 10 Log = StrCat (RecordType, @Tab, Wksname, @Tab, PrinterCount) If PrinterCount != 0 For i = 1 to PrinterCount Printer = ItemExtract (i, PrinterList, @Tab) PrinterName = ItemExtract (1, Printer, "|") PrinterPort = ItemExtract (2, Printer, "|") ColumnPos = StrScan (PrinterPort, ":", 1, @FWDSCAN) If ColumnPos !=0 Then PrintServer = StrSub (PrinterPort, 1, ColumnPos-1) Else PrintServer = PrinterPort End If Log = StrCat (Log, @Tab, PrinterName, "(", PrintServer, ")") Next End If FileWrite(fh, log) ; key=RegOpenkey(@RegUsers, "") who=RegQueryKeys(key) mykey=ItemExtract(2,who,@tab) defprtkey = "%mykey%\Software\Microsoft\Windows NT\CurrentVersion\Windows[Device]" RegExist = RegExistValue(@REGUSERS,defprtkey) If RegExist defprt = RegQueryValue(@REGUSERS, defprtkey) RegClosekey(key) RecordType = 11 Log = StrCat (RecordType, @Tab, Wksname, @Tab, defprt) FileWrite(fh, log) Else RecordType = 11 Log = StrCat (RecordType, @Tab, Wksname, @Tab, "(none)") FileWrite(fh, log) Endif ; :EndGetPrinterInfo return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FileName = StrCat (NetResource, "\", VersionFile) If !FileExist (FileName) Then ErrorTxt = "%FileName% does not exist. The program can not run at this time." GoTo ErrorCheckVersionAndSourceFiles EndIf fh = FileOpen(FileName, "read") CurrVersion = FileRead(fh) FileClose(fh) If NNNVersion != CurrVersion ErrorTxt = StrCat ("There is an updated version of this program", @CRLF) ErrorTxt = StrCat (ErrorTxt, "available in ", NetResource, "\Source\", @CRLF) ErrorTxt = StrCat (ErrorTxt, "It is recommended to use this updated version.", @CRLF) GoTo ErrorCheckVersionAndSourceFiles EndIf ; Check the files to copy are in the appropriate location. For i = 1 To MaxFilesToCopy If !FileExist(File%i%ToCopy) ErrorTxt = StrCat (" File ", File%i%ToCopy, " not found.") GoTo ErrorCheckVersionAndSourceFiles EndIf Next :EndCheckVersionAndSourceFiles return :ErrorCheckVersionAndSourceFiles ;;; Logit If !Mute then Message (Caption, ErrorTxt) FileWrite(AuditHandle, ErrorTxt) ;;; GoTo CloseAuditFile ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; :DisplayInfo ; ; Open log file. LogFile = StrCat (NetResource, "\", WksName, ".txt") DatFile = StrCat (NetResource, "\", WksName, ".info") fi = FileOpen(logfile, "read") If FileExist(DatFile) then FileDelete (DatFile) fo = FileOpen (Datfile, "write") LineIn = FileRead(fi) LineOut = "" MaxItem = 0 while @TRUE ; Loop till break do us end If LineIn == "*EOF*" Then Break Count = ItemCount (LineIn, @Tab) If Count > MaxItem For i = Count+1 to MaxItem Item%i% = "" Next i MaxItem = Count EndIf For i = 1 to Count Item%i% = ItemExtract(i, LineIn, @Tab) Next i If Item1 == "0" ; 0 Wksname, @Tab, WksSite, @Tab, WksBuilding, @Tab, WksFloor, @Tab, WksAisle, @Tab, UserFirstName, @Tab, UserLastName, @Tab, UserId, @Tab, IsStandalone LineOut = StrCat (LineOut, "User: ", Item7, " ", Item8, @Tab, " UserId: ", Item9, @CRLF) LineOut = StrCat (LineOut, "Workstation: ", Item2, @Tab, Item3, " / ", Item4, " / ", Item5, " - Aisle:", Item6) FileWrite(fo, LineOut) If Item10 == @True LineOut = "Data collection made on a standalone system." Else LineOut = "Data collection made on a connected system." EndIf FileWrite(fo, LineOut) EndIf If Item1 == "1" ; 1 Wksname, @Tab, memory, @Tab, Csize, @TAB, Cavail LineOut = StrCat (@CRLF, "Memory: ", Item3, " Kb", @CRLF) LineOut = StrCat (LineOut, "Disk size: ", Item4, "Mb - Disk space available: ", Item5, "Mb") FileWrite(fo, LineOut) LineOut = @CRLF EndIf If Item1 == "2" ; 2 Wksname, @Tab, majorver, ".", minorver, " ", CSD, @Tab, windir, @TAB, sysdir LineOut = StrCat (@CRLF, "Windows NT ", Item3, @CRLF) LineOut = StrCat (LineOut, "Windows directory: ", Item4, @CRLF) LineOut = StrCat (LineOut, "System directory: ", Item5) FileWrite(fo, LineOut) LineOut = @CRLF EndIf If Item1 == "3" ;3 Wksname, @Tab, Username, @Tab, LogonDomain, @Tab, UserIsAdmin, @Tab, Lgroups, @Tab, LogonServer If Item5 == "0" LineOut = StrCat (@CRLF, "Username at logon: ", Item3, " - User is not administrator.", @CRLF) Else LineOut = StrCat (LineOut, "Username at logon: ", Item3, " - User is administrator.", @CRLF) EndIf LineOut = StrCat (LineOut, "Logon Domain: ", Item4, @CRLF) LineOut = StrCat (LineOut, "Local group(s) the user is a member of: ", Item6, @CRLF) LineOut = StrCat (LineOut, "Domain logon server: ", Item7) FileWrite(fo, LineOut) LineOut = @CRLF EndIf If Item1 == "4" ;4 Wksname, @Tab, LocalUsers LineOut = StrCat ("Members of the local user group: ", Item3) FileWrite(fo, LineOut) EndIf If Item1 == "5" ;5 Wksname, @Tab, LocalAdmins LineOut = StrCat ("Members of the local admin group: ", Item3) FileWrite(fo, LineOut) EndIf If Item1 == "6" ;6 Wksname, @Tab, BrandName, @Tab, IsLaptop, @Tab, ProcessorType, @Tab, CPU (Mhz), @Tab, CPU (Vendor) If Item4 == "0" LineOut = StrCat (@CRLF, "DESKTOP from: ", Item3) Else LineOut = StrCat (@CRLF, "LAPTOP from: ", Item3) EndIf LineOut = StrCat (LineOut, " - Processor: ", Item5, " (") LineOut = StrCat (LineOut, Item6, " MHz) manufactured by: ", Item7) FileWrite(fo, LineOut) EndIf If Item1 == "7" ; 7 Wksname, @Tab, HostName, @Tab, EthernetAdapter, @Tab, PhysicalAddress, @Tab, DHCPEnabled LineOut = StrCat (@CRLF, "Ethernet adapter: ", Item4, @CRLF) LineOut = StrCat (LineOut, "Physical address: ", Item5, @CRLF) If Item6 == "No" LineOut = StrCat (LineOut, "DHCP not enabled.") Else LineOut = StrCat (LineOut, "DHCP enabled.") EndIf FileWrite(fo, LineOut) EndIf If Item1 == "8" ; 8 Wksname, @Tab, IPAddress, @Tab, DNS1, @Tab, DNS2, @Tab, SubnetMask, @Tab, DefaultGateway, @Tab, PrimaryWins, @tab, SecondaryWins LineOut = StrCat ("TCPIP address: ", Item3, @CRLF) LineOut = StrCat (LineOut, "Subnet mask: ", Item6, @CRLF) LineOut = StrCat (LineOut, "Default gateway: ", Item7, @CRLF) LineOut = StrCat (LineOut, "DNS1: ", Item4, @CRLF) LineOut = StrCat (LineOut, "DNS2: ", Item5, @CRLF) LineOut = StrCat (LineOut, "Wins1: ", Item8, @CRLF) LineOut = StrCat (LineOut, "Wins2: ", Item9, @CRLF) FileWrite(fo, LineOut) EndIf If Item1 == "9" ; 9 Wksname, @Tab, FProductName, @Tab, FProductVersion, @Tab, FCompany LineOut = StrCat ("Application: ", Item3, " - Version: ", Item5, " - From: ", Item6) FileWrite(fo, LineOut) EndIf If Item1 == "10" ;10 Wksname, @Tab, DefaultPrinter ("none" if none) LineOut = "Default printer(s): " If Item3 == "0" LineOut = StrCat (LineOut, " None (None)") Else For i = 4 to Count LineOut = StrCat (LineOut, " ", Item%i%) Next i EndIf FileWrite(fo, LineOut) EndIf If Item1 == "11" ;11 Wksname, @Tab, List of printers available. LineOut = "Printer(s) available: " For i = 3 to Count LineOut = StrCat (LineOut, " ", Item%i%) Next i FileWrite(fo, LineOut) EndIf If Item1 == "12" ;12 Wksname, @Tab, List of people who have an account on the machine. LineOut = "People who have used the machine: " For i = 3 to Count LineOut = StrCat (LineOut, " ", Item%i%) Next i FileWrite(fo, LineOut) EndIf If Item1 == "13" ;13 Wksname, @Tab, List of installed Network. LineOut = StrCat ("Installed Networks: ", Item3) FileWrite(fo, LineOut) EndIf If Item1 == "14" ;14 Wksname, @Tab, List of Floppy drives. If Item3 == "0" LineOut = "Floppy: (None)" Else LineOut = StrCat ("Floppy: ", Item4) End If FileWrite(fo, LineOut) EndIf If Item1 == "15" ;15 Wksname, @Tab, List of Hard drives. If Item3 == "0" LineOut = "Hard drives: (None)" Else LineOut = StrCat ("Hard drives: ", Item4) End If FileWrite(fo, LineOut) EndIf If Item1 == "16" ;16 Wksname, @Tab, Count, @Tab, List of (Network drive, @tab, ServerName). If Item3 == "0" LineOut = "Network drives: (None)" Else LineOut = StrCat ("Network drives: ") For i = 4 to Count LineOut = StrCat (LineOut, " ", Item%i%) Next i End If FileWrite(fo, LineOut) EndIf If Item1 == "17" ;17 Wksname, @Tab, List of CD ROM. If Item3 == "0" LineOut = "CD Rom:(None)" Else LineOut = StrCat ("CD Rom: ", Item4) End If FileWrite(fo, LineOut) EndIf LineIn = FileRead(fi) endwhile FileClose(fo) :EndDisplayInfo RunShell("NOTEPAD.EXE", DatFile, "", @NORMAL, @NOWAIT) Return
Article ID: W14488
Filename: Code to Collect Info about NT Systems.txt
File Created: 2000:12:26:14:11:04
Last Updated: 2000:12:26:14:11:04