No KiXtart.org Moderators or Administrators aside from myself are allowed to post in this thread.
(This is for those with less experience to learn, not for bored, experienced users to bump their post count)
(If you're able to easily do this task then please don't participate with any solutions)
No using IM,PM, KiXtart.org search feature, or Google to locate/find an answer (you're on the honor system here).
The only help you're allowed to use is the KiXtart User Manual. Please be honest and don't use other resources
All submitted code must be as though it were to be used in production. ie.. code should set options and have error checks as well as documentation of what the code is doing. Error checking does not need to be extensive but should have some basic check.
Read local and remote registry to obtain a value
Create and modify an .INI file with values read from the Registry
Modify the .INI to include the current PID of KIX32.EXE or WKIX32.EXE
Execute a second script that has a different Process ID Number and add to the .INI it's value
Pick 5 computers from your network and read the timeout value from their boot.ini file then input that value into the new INI you created.
Given strings with variable length locate the term NOW and return the first character before it and after it and place in the INI file (exclude/ignore blank space before or after the term)
DO NOT post a solution until Tuesday, Oct 10, 2006.
I will make a post on Tuesday to indicate when you can post a solution.
If I've made an error or have not provided enough information you can post asking for clarification but please do not post any solutions until Tuesday.
Details for objectives
Create an INI file in the same folder the script runs from named KiX-Lesson03.ini The case of the saved file name is to be maintained.
Modify the VALUE entry in the INI with the returned value. The value must include the full path of the local and remote system and not just the variable.
Remotely read the BOOT.INI timeout value of 5 computers on your network and enter the value into the KiX-Lesson03.ini file as show above where SYSTEMNAME is the real name of the system as well as the DATE and TIME the file was last modified.
Return the the DATE in this format MMDDYYYY-HHMMSS
The quick or was it now slow fox ran in the snow
The snow in France is now gone but will return again next Winter
There is now a slow return on investments at the bank
Doc, I presume the date when the boot.ini was last changed has to be included in the value for the keys "REMOTE_COMPUTERNAME_0x_TIMEOUT". But how should te format of the value be? Maybe "ss MMDDYYYY-HHMMSS" where lowercase ss is the timeout in seconds?
$BitMapComp[0,0] = "\\.\" $BitMapComp[0,1] = "LOCAL_SYSTEM_Bitmap" $BitMapComp[1,0] = "\\sacs\" $BitMapComp[1,1] = "REMOTE_SYSTEM_2K_Bitmap" $BitMapComp[2,0] = "\\srdc\" $BitMapComp[2,1] = "REMOTE_SYSTEM_XP_2K3_Bitmap" $TimeOutComp = "srdc","sacs","sutil","svhost04","x019678" $String1 = "The quick or was it now slow fox ran in the snow" $String2 = "The snow in France is now gone but will return again next Winter" $String3 = "There is now a slow return on investments at the bank" ;*************************************************************************
;Get the BitMap Entries For $count = 0 to Ubound($BitMapComp) $SO = Bitmap($BitMapComp[$Count,0],$BitMapComp[$Count,1]) Next
;Get the timeout values $Count = 1 For each $element in $TimeOutComp Timeouts($Element,$Count) $Count = $Count + 1 Next
;Get the requested String info FindInString($String1,"Now",1) FindInString($String2,"Now",2) FindInString($String3,"Now",3)
Function Bitmap($Comp, $Value) ;Now we need the Bitmap value to add to the INI file $Bitmap = Readvalue($Comp+"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder","Bitmap")
;And since we can not include any variables in the output ;Not sure about this part for the remote systems.... It appears to be working correctly ;However how does one know for sure? $Bitmap = ExpandEnvironmentVars($Bitmap)
;And write it to the ini $SO = WriteProfileString(@scriptdir+"\KiX-Lesson03.ini","LESSON_03",$Value,$Bitmap)
;Get the Timeout Value from specified computer $Time = ReadProfileString("\\"+$Comp+"\"+"C$\Boot.ini","Boot Loader","TimeOut")
;Get the last Modified time of the Boot.ini file $Date = GetFileTime("\\"+$comp+"\"+"C$\Boot.ini")
;Split the string in half so we can rearrange to specifications $Date = Split($Date," ")
;Split the date apart so that it can be rearranged $DateSplit = Split($Date,"/")
;Rearrange the date and write it back to the same variable $DateSplit = $DateSplit + $DateSplit+$DateSplit
;Now make a single variable from the 2 in the specified format $Date = $DateSplit + "-" + Join(Split($Date,":"),"")
;Write the information to the INI file $SO = WriteProfileString(@scriptdir+"\KiX-Lesson03.ini","LESSON_03","REMOTE_"+$Comp+"_0"+$Count+"_TIMEOUT",$Time+" "+$date)
Function FindInString($StringToRead,$SearchPhrase,$Count) Dim $Array,$Position,$ActualValue
;Split up the string $Array = Split($StringToRead," ")
;Look For the phrase that was passed $Position = Ascan($Array,$SearchPhrase)
;Now that we know where the phrase is, Get the requested info $ActualValue = Right($Array[$Position-1],1) + Left($Array[$Position+1],1)
;Write the information to the INI file $SO = WriteProfileString(@scriptdir+"\KiX-Lesson03.ini","LESSON_03","RANDOM_STRING"+$Count,$ActualValue)
I can see though that as noticed in a previous lesson that you're well above the "noobie" point in scripting
Thanks, but this took some definite looking through the manual for me. That and lots of ? to the console so I could figure out what I was really looking at. You definatly made me think about exactly what was happening. And I did my first Split - Join combo.
Okay I'll have to apologize as I picked a Registry key that did not have the proper characteristics of what I was attempting to show.
Basically I wanted to demonstrate that you could not use the ExpandEnvironmentVars to obtain the data from a remote system. If it was the same version OS and all default installation directories you could "assume" but that still would not be the best action to take. You should code something that would give the correct results regardless of the installation directory.
Reminder that these are "my opinions" and may not be 100% in line with ideas / recommendations of other experienced scripters.
If other Admins, Moderators, or experienced scripters see something that I've commented on that is just plain wrong please join in, however if it is just your own personal preferences or method then please don't do so at this time.
As always there are many ways, methods, styles of scripting and one can not always say that one way is always better than another.
Doesn't matter if I've learned it or not - my scripting needs to improve a great bit - I enjoy it - so it needs to work :). checking it now, cannot really do much with remote puters since I'm not home and on vacation. Night is long, and the bottle of scotch is not even down to half - I have time to figure this out I think
(edit: one and a half bottle of 'scotch' later, and I kinda slipped away from scripting somehow.. , just found the old results, and might get some time soon again )