; IF setconsole("hide") ; ENDIF ; ; NT/95 inventory - Kixtart 3.62, 3.63, 4.00 ; ; (c) scripting@wanadoo.nl - 1999, 2000, 2001 ; ; vs 3.07 - program ; ; 1.00 (19990301) original version. ; 3.00 (20010330) - update (= 4.12) ; 3.01 (20010401) - introduction of $display modes ; 3.02 (20010401) - kixtart 2001 beta1 compliancy ; - add user information about output generation ; 3.03 (20010701) - using %tmp% value ; - kixtart 2001 RC1 compliancy with GetDiskSpace ; 3.04 (20010710) - standardization of $debug_file value ; 3.05 (20011115) - "kix-info.log" was used as file and as directory. ; directory name changed to "kix-info" ; 3.06 (20011120) - add "windows XP" ; - suppress SetConsole("hide") ; 3.07 (20011205) - suppress SetConsole("hide") ; ; special variables: $file, $section, $key, $user ; $debug_mode, ; $NT_mode, ; $tmp (= initial value of each record) ; $time_start, $time_stop ; other variables: $domain, $ldomain ; temporary variables: $ikey, $icode, $ivalue ; $prgrm_version="3.07" ; $time_start=@time $time_stop=@time ; $tmp_directory=ExpandEnvironmentVars("%tmp%") IF (substr($tmp_directory,len($tmp_directory),1) = "\") $tmp_directory=substr($tmp_directory,1,len($tmp_directory)-1) ENDIF ; MD $tmp_directory IF (@error = 0) ENDIF ; --------------------------------------------------------------------------- ; - site defined settings - ; --------------------------------------------------------------------------- $debug_mode="yes" ; - yes/no - $debug_file=$tmp_directory+"\kix-info.log" IF ($debug_mode = "yes") $log_path=$tmp_directory+"\" ; (extended with: \kix-info\$domain) ELSE $log_path="c:\" ; (extended with: \kix-info\$domain) ENDIF $display_address_lst="yes" $display_ip_lst="yes" $display_ip_mac_lst="yes" $display_mac_ip_lst="yes" $display_pc_lst="yes" $display_user_lst="yes" ; --------------------------------------------------------------------------- ; - - ; --------------------------------------------------------------------------- IF (@inwin = 1) $NT_mode="yes" ELSE $NT_mode="no" ENDIF IF (len(@ipaddress0) = 0) $offline_mode="yes" ELSE $offline_mode="no" ENDIF ; IF (exist($debug_file) = 1) del $debug_file ENDIF $os="" $os_dos=@dos SELECT CASE ($NT_mode = "yes") AND ($os_dos = "5.1") ; - Windows XP - $os="XP" CASE ($NT_mode = "yes") AND ($os_dos = "5.0") ; - Windows 2000 - $os="W2K" CASE ($NT_mode = "yes") ; - Windows NT - $os="NT4" CASE ($NT_mode <> "yes") AND ($os_dos = "4.90") ; - Windows ME - $os="ME" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") ; - Windows 98 - $os="W98" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") ; - Windows 95 - $os="W95" CASE 1 $os="???" ; - undetermined - ENDSELECT $domain="" $ldomain="" IF ($NT_mode = "yes") $ikey="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" IF (existkey($ikey) = 0) $domain=ReadValue($ikey, "DefaultDomainName") ENDIF $ikey="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" IF (existkey($ikey) = 0) $ldomain=ReadValue($ikey, "CachePrimaryDomain") ENDIF ELSE $ikey="HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MSNP2\NetworkProvider" IF (existkey($ikey) = 0) $domain=ReadValue($ikey, "AuthenticatingAgent") ENDIF $ikey="HKEY_LOCAL_MACHINE\Security\Provider" IF (existkey($ikey) = 0) $ldomain=ReadValue($ikey, "Container") ENDIF ENDIF IF (len($domain) = 0) IF (len(@ldomain) <> 0) $domain=@ldomain ELSE $domain=@domain ENDIF IF (len($domain) = 0) $domain="~domain" ; - unknown @domain/@ldomain value - ENDIF ENDIF IF (len($ldomain) = 0) $ldomain=$domain ENDIF ; break off MD $tmp_directory IF (@error = 0) ENDIF IF ($debug_mode = "yes") break on ? "KIX-INFO: DEVELOPMENT ("+$os+" - kixtart "+@kix+" vs "+$prgrm_version+")" ? IF (RedirectOutput($debug_file,1) = 0) ENDIF ELSE IF (RedirectOutput("nul",1) = 0) ENDIF ENDIF flushkb IF ($NT_mode = "yes") $time_stop=@time $log_info="Kixtart-info "+$prgrm_version+" script started" $log_info=$log_info+" for '"+LCASE(@userid)+"'" $log_info=$log_info+" ("+$time_start+" - '"+@ipaddress0+"')" IF logevent(0, 1, $log_info, "", "Kixtart INFO @kix") ENDIF ENDIF ; IF (substr($log_path,len($log_path),1) = '\') $log_path=LTRIM(RTRIM(substr($log_path,1,len($log_path)-1))) ENDIF $file=$log_path IF (exist($log_path+"\kix-info\"+$domain) = 0) MD $log_path+"\kix-info" IF (@error = 0) ENDIF MD $log_path+"\kix-info\"+$domain IF (@error = 0) $file=$file+"\kix-info\"+$domain+"\" ENDIF ELSE $file=$file+"\kix-info\"+$domain+"\" ENDIF ; -------------------------------------------------------------------------- ; - special variables settings - ; -------------------------------------------------------------------------- $section=substr(@date,1,4) IF (@ydayno < 10) $section=$section+"00"+@ydayno ELSE IF (@ydayno < 100) $section=$section+"0"+@ydayno ELSE $section=$section+@ydayno ENDIF ENDIF $key=$section+"_" $key=$key+substr(@date,3,2)+substr(@date,6,2)+substr(@date,9,2) $key=$key+"_" $key=$key+@time $key=$key+" "+$domain $x="" $tmp="" IF (len(@ipaddress0) = 0) $offline_mode="yes" $x=$x+"("+$os+" - vs "+$prgrm_version+" - off-line )" ELSE $offline_mode="no" IF (len(@lserver) = 0) $lserver="~lserver " ELSE $lserver=@lserver ENDIF IF (LCASE($domain) = LCASE($ldomain)) $x=$x+"("+$os+" - vs "+$prgrm_version+" L $domain $lserver)" ELSE $x=$x+"("+$os+" - vs "+$prgrm_version+" - $domain $lserver)" ENDIF ENDIF IF (len(@ipaddress0) = 15) $i=1 $ip_old=@ipaddress0 $ip_new="" DO IF (substr($ip_old,$i,1) <> " ") $ip_new=$ip_new+substr($ip_old,$i,1) ELSE $ip_new=$ip_new+"0" ENDIF $i=$i+1 UNTIL ($i > 15) ELSE $ip_new="xxx.xxx.xxx.xxx" ENDIF $x=$x+" "+$ip_new IF (len(@address) = 0) $address="xxxxxxxxxxxx" ELSE $address=@address ENDIF $x=$x+" "+$address $user="" IF ($NT_mode = "yes") $ikey="HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" IF (existkey($ikey) = 0) $user=ReadValue($ikey, "DefaultUserName") ENDIF ELSE $ikey="HKEY_LOCAL_MACHINE\System\CurrentControlSet\control" IF (existkey($ikey) = 0) $user=ReadValue($ikey, "Current User") ENDIF ENDIF IF (len($user) = 0) $user=@userid IF (len($user) = 0) $user="~user" ENDIF ENDIF $x=$x+" "+$user IF (len(@wksta) = 0) $x=$x+" ~wksta" ELSE $x=$x+" "+@wksta ENDIF IF (len(@fullname) = 0) IF (len(@comment) = 0) $x=$x+" ('~fullname')" ELSE $x=$x+" ('~fullname'+'"+@comment+"')" ENDIF ELSE IF (len(@comment) = 0) $x=$x+" ('@fullname')" ELSE $x=$x+" ('"+@fullname+"'+'"+@comment+"')" ENDIF ENDIF $tmp=$x IF ($debug_mode = "yes") IF (len(@ipaddress0) = 0) ? "Kixtart "+@kix+" - "+$os+" debug mode (vs "+$prgrm_version+")"+" "+@time+" (off-line)" ELSE ? "Kixtart "+@kix+" - "+$os+" debug mode (vs "+$prgrm_version+")"+" "+@time+" (on-line)" ENDIF ? ? "file "+$file ? "section "+$section ? "key "+$key IF (len(@fullname) = 0) ? "user "+$user ELSE IF (len(@comment) = 0) ? "user "+$user+" ('"+@fullname+"')" ELSE ? "user "+$user+" ('"+@fullname+"'+'"+@comment+"')" ENDIF ENDIF ? ? "workstation "+@wksta+" ("+LCASE(@lanroot)+") C="+GetDiskSpace("c:\")+" KBytes" ? "domain "+@domain ? "ldomain "+@ldomain ? " -> = "+$domain ? " "+$ldomain+" (L)" ? "ip_adress "+$ip_new+" "+$address ? ? " key settings"+" -> "+$log_path ? ? "debug_mode "+$debug_mode ? "offline_mode "+$offline_mode ? ? "display address.lst "+$display_address_lst ? "display ip.lst "+$display_ip_lst ? "display ip_mac.lst "+$display_ip_mac_lst ? "display mac_ip.lst "+$display_mac_ip_lst ? "display pc.lst "+$display_pc_lst ? "display user.lst "+$display_user_lst ? ENDIF ; --------------------------------------------------------------------------- ; - logfiles: address.lst, ip.lst, ip-mac.lst, mac-ip.lst, pc.lst, user.lst - ; --------------------------------------------------------------------------- :script_logfiles $file_x=$log_path+"\kix-info\"+$domain+"\" IF ($debug_mode = "yes") ? ? " ---------------------------------------------------------" ? " Kixtart "+@kix+" - debug mode (vs "+$prgrm_version+") ADDITIONAL INFORMATION" ? " ---------------------------------------------------------" ? ENDIF ; ----- additional logfiles - (part 1: Address.LST) ----- $file_y=$file_x+"address.lst" $section_x=$domain $key_x=$address+" "+$section_x IF (@kix = "3.55") OR (@kix = "3.62") OR (@kix = "3.63") OR (substr(@kix,1,1) = "4") $xxx=$key+" "+$tmp+" C=("+GetDiskSpace("c:\")+" KBytes)" ELSE $xxx=$key+" "+$tmp ENDIF ; IF ($debug_mode = "yes") ? ? " file_y = "+$file_y ? " section_x = "+$section_x ? " key_x = "+$key_x ? " xxx = "+$xxx ? ENDIF IF ($display_address_lst = "yes") IF writeprofilestring($file_y, $section_x, $key_x, $xxx) ENDIF ELSE IF ($debug_mode = "yes") ? " -skip- address.lst" ENDIF ENDIF ; ----- additional logfiles - (part 2: IP.LST) ----- $file_y=$file_x+"ip.lst" $section_x=$domain $key_x=$ip_new+" "+$section_x IF (@kix = "3.55") OR (@kix = "3.62") OR (@kix = "3.63") OR (substr(@kix,1,1) = "4") $xxx=$key+" "+$tmp+" C=("+GetDiskSpace("c:\")+" KBytes)" ELSE $xxx=$key+" "+$tmp ENDIF ; IF ($debug_mode = "yes") ? ? " file_y = "+$file_y ? " section_x = "+$section_x ? " key_x = "+$key_x ? " xxx = "+$xxx ? ENDIF IF ($display_ip_lst = "yes") IF writeprofilestring($file_y, $section_x, $key_x, $xxx) ENDIF ELSE IF ($debug_mode = "yes") ? " -skip- ip.lst" ENDIF ENDIF ; ----- additional logfiles - (part 3: PC.LST) ----- $file_y=$file_x+"pc.lst" $section_x=$domain $key_x=substr(LCASE(@wksta)+" ",1,15)+" " $key_x=$key_x+$section_x IF (@kix = "3.55") OR (@kix = "3.62") OR (@kix = "3.63") OR (substr(@kix,1,1) = "4") $xxx=$key+" "+$tmp+" C=("+GetDiskSpace("c:\")+" KBytes)" ELSE $xxx=$key+" "+$tmp ENDIF ; IF ($debug_mode = "yes") ? ? " file_y = "+$file_y ? " section_x = "+$section_x ? " key_x = "+$key_x ? " xxx = "+$xxx ? ENDIF IF ($display_pc_lst = "yes") IF writeprofilestring($file_y, $section_x, $key_x, $xxx) ENDIF ELSE IF ($debug_mode = "yes") ? " -skip- pc.lst" ENDIF ENDIF ; ----- additional logfiles - (part 4: User.LST) ----- $file_y=$file_x+"user.lst" $section_x=$domain+"_"+$os $key_x=substr(LCASE($user)+" ",1,15)+" " $key_x=$key_x+$section_x IF (@kix = "3.55") OR (@kix = "3.62") OR (@kix = "3.63") OR (substr(@kix,1,1) = "4") $xxx=$key+" "+$tmp+" C=("+GetDiskSpace("c:\")+" KBytes)" ELSE $xxx=$key+" "+$tmp ENDIF ; IF ($debug_mode = "yes") ? ? " file_y = "+$file_y ? " section_x = "+$section_x ? " key_x = "+$key_x ? " xxx = "+$xxx ? ENDIF IF ($display_user_lst = "yes") IF writeprofilestring($file_y, $section_x, $key_x, $xxx) ENDIF ELSE IF ($debug_mode = "yes") ? " -skip- user.lst" ENDIF ENDIF ; ----- additional logfiles - (part 5a: IP-MAC.LST) ----- $file_y=$file_x+"ip-mac.lst" $section_x=$domain $key_x=$ip_new+" "+$address+" "+$section_x $xxx=$key+" "+$tmp ; IF ($debug_mode = "yes") ? ? " file_y = "+$file_y ? " section_x = "+$section_x ? " key_x = "+$key_x ? " xxx = "+$xxx ? ENDIF IF ($display_ip_mac_lst = "yes") IF writeprofilestring($file_y, $section_x, $key_x, $xxx) ENDIF ELSE IF ($debug_mode = "yes") ? " -skip- ip-mac.lst" ENDIF ENDIF ; ----- additional logfiles - (part 5b: MAC-IP.LST) ----- $file_y=$file_x+"mac-ip.lst" $section_x=$domain $key_x=$address+" "+$ip_new+" "+$section_x $xxx=$key+" "+$tmp ; IF ($debug_mode = "yes") ? ? " file_y = "+$file_y ? " section_x = "+$section_x ? " key_x = "+$key_x ? " xxx = "+$xxx ? ENDIF IF ($display_mac_ip_lst = "yes") IF writeprofilestring($file_y, $section_x, $key_x, $xxx) ENDIF ELSE IF ($debug_mode = "yes") ? " -skip- mac-ip.lst" ENDIF ENDIF ; -------------------------------------------------------------------------- ; - end - ; -------------------------------------------------------------------------- :end_script $time_stop=@time IF ($NT_mode = "yes") $log_info="Kixtart-info "+$prgrm_version+" script completed successfully" $log_info=$log_info+" for '"+LCASE($user)+"' "+UCASE($domain) $log_info=$log_info+" ("+$time_start+" - "+$time_stop+" - '"+$ip_new+"')" IF (len(@fullname) > 0) $log_info=$log_info+" '"+LCASE(@fullname)+"'" ENDIF ; IF ($debug_mode = "yes") ? ? " logevent = "+$log_info ? ENDIF IF logevent(0, 1, $log_info, "", "Kixtart INFO @kix"+"c") ENDIF ENDIF IF ($debug_mode = "yes") cls IF setconsole("show") ENDIF ? ? "elapse time "+$time_start+" - "+$time_stop ? "completed" ? IF (RedirectOutput("") = 0) ENDIF ? IF ($debug_mode = "yes") ? "elapse time "+$time_start+" - "+$time_stop+" (kixtart "+@kix+" vs "+$prgrm_version+") -DEVELOPMENT-" ELSE ? "elapse time "+$time_start+" - "+$time_stop+" (kixtart "+@kix+" vs "+$prgrm_version+")" ENDIF IF ($offline_mode = "yes") ? "completed (off-line)" ELSE ? "completed (on-line)" ENDIF ? ? " -RUN SCRIPT ("+$log_path+")-" ? ENDIF IF ($debug_mode <> "yes") IF (exist($debug_file) = 1) del $debug_file ENDIF ENDIF ; IF (RedirectOutput("",1) = 0) ENDIF color C+/N IF ($debug_mode = "yes") ? "Informative Inventory.KIX: create debug list '"+$debug_file+"'" ELSE ? "Informative Inventory.KIX: no creation of debug list '"+$debug_file+"'" ENDIF ? "Informative Inventory.KIX: log location '"+$log_path+"\kix-info\"+$domain+"'" IF ($display_address_lst = "yes") ? "Informative Inventory.KIX: creation of dynamic list 'address.lst'" ENDIF IF ($display_ip_lst = "yes") ? "Informative Inventory.KIX: creation of dynamic list 'ip.lst'" ENDIF IF ($display_ip_mac_lst = "yes") ? "Informative Inventory.KIX: creation of dynamic list 'ip_mac.lst'" ENDIF IF ($display_mac_ip_lst = "yes") ? "Informative Inventory.KIX: creation of dynamic list 'mac_ip.lst'" ENDIF IF ($display_pc_lst = "yes") ? "Informative Inventory.KIX: creation of dynamic list 'pc.lst'" ENDIF IF ($display_user_lst = "yes") ? "Informative Inventory.KIX: creation of dynamic list 'user.lst'" ENDIF break on flushkb