Page 1 of 1 1
Topic Options
#139536 - 2005-05-11 12:30 AM Need a jump start...
xpanmanx Offline
Starting to like KiXtart

Registered: 2002-07-08
Posts: 108
Loc: St. Louis MO USA
Greetings,

I am writing a script for a client, who wants to make it simple for his field staff to reconfigure workstations as
they move between sites.

I want to keep a separate .INI file for each site, but the quantity of INIs may vary by workstation. I need for my
script to display a numbered list of all the .INI filescan a static directory, and accept a keypress to continue
execution using the specified .INI.

Would some kind sould please jump-start me on this?

My code thus far is below. Note that I am running with a static .INI file as a variable. Also please forgive the
lengthy (but very clear) variable names; this was a requirement of my client. I've also included a sample .INI .

Best regards,

Tim ==

Code:
;turn on the break key.if this command is not present, and the operator halts execution, the operator will be forcibly logged off.
Break on
? @scriptname
SetOption('wrapateol','on')
SetOption('explicit','on')
Dim $dummy,$location_ini,$windows_default_printer,$location_name,$ie_proxy_enable,$ie_automatically_detect_settings,
$ie_use_automatic_configuration_script,$ie_use_a_proxy_server_for_your_lan,$ie_do_not_use_proxy_server_for_addresses_beginning_with,
$fwc_enable,$fwc_manual_isa_server_name,$fwc_enable_browser_configuration

@crlf + @crlf

SetTitle (@scriptname)

;===============================================================================================
;===============================================================================================
;===============================================================================================
$location_ini='c:\dev\test.ini'
;===============================================================================================
;===============================================================================================
;===============================================================================================

CLS

Gosub READ_LOCATION_INI

Gosub CONFIGURE_IE

Gosub CONFIGURE_FWC

If $windows_default_printer <> '' Gosub CONFIGURE_PRINTER EndIf

Return

;===============================================================================================
:READ_LOCATION_INI

Color y/n ? '======================================' Color c+/n

? 'Reading ' + $location_ini
? '---'

If NOT Exist ($location_ini)
Color r+/n
? $location_ini + ' not be found. Exiting.'
Color c+/n
Beep
Sleep 3
Exit
EndIf

$location_name = ReadProfileString($location_ini,'location information','location name')

$ie_proxy_enable = ReadProfileString($location_ini,'ie proxy server settings','enable (true or false)')
$ie_automatically_detect_settings = ReadProfileString($location_ini,'ie proxy server settings',
'automatically detect settings (true or false)')
$ie_use_automatic_configuration_script = Ucase(ReadProfileString($location_ini,'ie proxy server settings',
'use automatic configuration script (url or false)'))
$ie_use_a_proxy_server_for_your_lan = Ucase(ReadProfileString($location_ini,'ie proxy server settings',
'use a proxy server for your lan (name:port or false)'))
$ie_do_not_use_proxy_server_for_addresses_beginning_with = Ucase(ReadProfileString($location_ini,'ie proxy server settings',
'do not use proxy server for addresses beginning with ( and/or urls seperated by commas)'))

$fwc_enable = ReadProfileString($location_ini,'fwc settings','enable (true or false)')
$fwc_manual_isa_server_name = Ucase(ReadProfileString($location_ini,'fwc settings',
'manual isa server name (fq server name or ip or false)'))
$fwc_enable_browser_configuration = ReadProfileString($location_ini,'fwc settings','enable browser configuration (true or false)')

$windows_default_printer = UCASE(ReadProfileString($location_ini,'printer settings','default printer (local name unc or false)'))

? 'location_name=' + $location_name
? 'ie_proxy_enable=' + $ie_proxy_enable
? 'ie_automatically_detect_settings=' + $ie_automatically_detect_settings
? 'ie_use_automatic_configuration_script=' + $ie_use_automatic_configuration_script
? 'ie_use_a_proxy_server_for_your_lan=' + $ie_use_a_proxy_server_for_your_lan
? 'ie_do_not_use_proxy_server_for_addresses_beginning_with=' + $ie_do_not_use_proxy_server_for_addresses_beginning_with

? 'fwc_enable=' + $fwc_enable
? 'fwc_manual_isa_server_name=' + $fwc_manual_isa_server_name
? 'fwc_enable_browser_configuration=' + $fwc_enable_browser_configuration

? 'windows_default_printer=' + $windows_default_printer

Color y/n ? '======================================' Color c+/n

Sleep 1

Return
;===============================================================================================

;===============================================================================================
:CONFIGURE_IE
;local machine ie proxy server settings
? '...configuring local machine IE Proxy Server settings.'

If $ie_proxy_enable = 'false' $dummy = DelValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings',
'proxyenable')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings',
'proxyenable','1','reg_dword')
EndIf

If $ie_use_a_proxy_server_for_your_lan = 'false' $dummy = DelValue('hkey_current_user\software\microsoft\windows\currentversion\' +
'internet settings','proxyserver')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings',
'proxyserver',$ie_use_a_proxy_server_for_your_lan,'reg_sz')
EndIf

If $ie_automatically_detect_settings = 'false' $dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\'+
'internet settings','autodetect','0','reg_binary')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','autodetect','1','reg_binary')
Endif

If $ie_use_automatic_configuration_script = 'false' $dummy = DelValue('hkey_current_user\software\microsoft\windows\'+
'currentversion\internet settings','autoconfigurl')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','autoconfigurl'
,$ie_use_automatic_configuration_script,'reg_sz')
EndIf

$dummy=WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','proxyoverride',
$ie_do_not_use_proxy_server_for_addresses_beginning_with,'reg_sz')

Sleep 1

;current user ie proxy server settings
? '...configuring current user IE Proxy Server settings.'

If $ie_proxy_enable = 'false' $dummy = DelValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings',
'proxyenable')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','proxyenable','1','reg_dword')
EndIf

If $ie_use_a_proxy_server_for_your_lan = 'false' $dummy = DelValue('hkey_current_user\software\microsoft\windows\'+
'currentversion\internet settings','proxyserver')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','proxyserver',
$ie_use_a_proxy_server_for_your_lan,'reg_sz')
EndIf

If $ie_automatically_detect_settings = 'false' $dummy = WriteValue('hkey_current_user\software\microsoft\windows\'+
'currentversion\internet settings','autodetect','0','reg_binary')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','autodetect','1','reg_binary')
EndIf

If $ie_use_automatic_configuration_script = 'false' $dummy = DelValue('hkey_current_user\software\microsoft\windows\'+
'currentversion\internet settings','autoconfigurl')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','autoconfigurl',
$ie_use_automatic_configuration_script,'reg_sz')
EndIf

$dummy=WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','proxyoverride',
$ie_do_not_use_proxy_server_for_addresses_beginning_with,'reg_sz')

Color y/n ? '======================================' Color c+/n

Sleep 1

Return
;===============================================================================================

;===============================================================================================
:CONFIGURE_FWC
;ms firewall client settings
? '...configuring ISA Server 2004 Firewall Client.'

If $fwc_enable = 'TRUE' Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" enable'
Else
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" disable'
EndIf

If $fwc_manual_isa_server_name = 'FALSE'
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" SetAutoDetectServer'
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" TestAutoDetect'
Else
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" setmanualserver /server:' + $fwc_manual_isa_server_name
EndIf

If $fwc_enable_browser_configuration = 'FALSE' Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" disablebrowserconfig'
Else
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" enablebrowserconfig'
EndIf

Color y/n ? '======================================' Color c+/n

Sleep 1

Return
;===============================================================================================

;===============================================================================================
:CONFIGURE_PRINTER

? '...setting Windows default printer.'

$dummy = AddPrinterConnection($windows_default_printer)
$dummy = SetDefaultPrinter($windows_default_printer)

Color y/n ? '======================================' Color c+/n

Sleep 1

Return
;===============================================================================================


Code:
[Location Information]
Location name=CLIENT1

[IE proxy server settings]
Enable (TRUE or FALSE)=TRUE
Automatically detect settings (TRUE or FALSE)=FALSE
Use automatic configuration script (URL or FALSE)=FALSE
Use a proxy server for your LAN (NAME:PORT or FALSE)=PROXY:80
Do not use proxy server for addresses beginning with ( and/or URLS seperated by commas)=

[FWC settings]
Enable (TRUE or FALSE)=TRUE
Manual ISA Server name (FQ Server Name or IP or FALSE)=PROXY
Enable browser configuration (TRUE or FALSE)=False

[Printer settings]
Default printer (Local name UNC or FALSE)=\\server\lj4Code:



NOTE: Code has been modified by NTDOC to remove LONG LINES
Code is no longer as the poster intended it to look
  

Edited by NTDOC (2005-05-12 08:23 PM)

Top
#139537 - 2005-05-11 02:13 AM Re: Need a jump start...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Please break the long lines in your code so that it can
be read easier.

Also, what specifically do you mean reconfigure between sites?
What do you want to change?
Do you mean an Active Directory site or some other type of site?
What version of KiXtart are you using?
What client types are there?

Top
#139538 - 2005-05-11 06:39 PM Re: Need a jump start...
xpanmanx Offline
Starting to like KiXtart

Registered: 2002-07-08
Posts: 108
Loc: St. Louis MO USA
Thanks, NTDOC...but I don't need anyone to review my existing code. I provided it only to show that I'm capable of thinking for myself :->

This is a IE proxy settings and MS Firewall Client reconfiguration tool.

If I could figure out how to edit my OP, I'd break the long lines for you. I'd also post the changes which I've recently made.

By sites, I mean "physical sites", or businesses, hotels and coffee shops. My client's field staff are constantly on the go and they need a very simple way to reconfigure their browsers and printers as they move from site to site.

I am using KiXtart 4.50 beta 2a.

There are only WinXP clients, but they are a mix of RTM, SP1 and SP2.)

What I need is a function that will enumerate all of the .INI files in a folder, then generate a numbered menu of those files for the operator to choose, and exit with the name of the file as a new variable.

I freely admit that this is quite beyond my skill and experience; hence the title of the thread.

I'd prefer for the solution to run in a KiXtart DOS box, as I have very little VB, and no KiXforms, experience.

Top
#139539 - 2005-05-12 02:11 PM Re: Need a jump start...
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Hi xpanmanx

You could do with a choice box. Something like the below:

Code:
 

Break on
CLS

?
?
?" IMAGES"
?
?
?" 1 - Cashier"
?" 2 - Fasttrack"
?" 3 - Infoconnect"
?" 4 - Office Standard"
?" 5 - Office Professional"
?" 6 - ODBC 16 Bit"
?" 7 - Outlook 97 - Exchange Client"
?" 8 - Phonedisc"
?" 9 - Registry Entries for Printers"
?" 10 - System changes"
?" 11 - JetForms"
?
?

?" Please enter the number associated with the image to be applied :"
Gets $NUMBER

Select
Case $NUMBER=1
$IMAGE="Cashier"
Case $NUMBER=2
$IMAGE="Fasttrack"
Case $NUMBER=3
$IMAGE="Infoconn"
Case $NUMBER=4
$IMAGE="Msoffstd"
Case $NUMBER=5
$IMAGE="Msoffpro"
Case $NUMBER=6
$IMAGE="odbc16bit"
Case $NUMBER=7
$IMAGE="outlook97"
Case $NUMBER=8
$IMAGE="phonedisc"
Case $NUMBER=9
$IMAGE="registryprn"
Case $NUMBER=10
$IMAGE="system"
Case $NUMBER=11
$IMAGE="jetforms"
EndSelect



Run "\\blah\blah\blah\blah\sysdiff.exe /apply /m \\blah\blah\blah\blah\$image.img"

Exit 1




This is a sample code but should give you some ideas. Hope this helps

Aaron
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#139540 - 2005-05-12 04:57 PM Re: Need a jump start...
xpanmanx Offline
Starting to like KiXtart

Registered: 2002-07-08
Posts: 108
Loc: St. Louis MO USA
Thanks, Aaron - what I'm hoping for is a function which discovers and enumertes the .INI files, rather than a list of specified filenames.

The INIs may not always be of the same name, or quantity. For instance, if a user creates a .INI for his home network, and a few for some hotels which he frequents, I want the function to be able to pick up those filenames, and present them for selection, "automagically".

Thanks for the suggestion, though! :>

Top
#139541 - 2005-05-12 05:06 PM Re: Need a jump start...
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
about how many ini's we talking about?
Top
#139542 - 2005-05-13 01:56 AM Re: Need a jump start...
xpanmanx Offline
Starting to like KiXtart

Registered: 2002-07-08
Posts: 108
Loc: St. Louis MO USA
It would be nice to get into double-digits, but if it greatly simplifies the input routines I can keep it to 9 or fewer.
Top
#139543 - 2005-05-13 06:40 AM Re: Need a jump start...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Are you willing to go with KiXforms? http://www.kixforms.com

If not that's okay it can still be done, but using KiXforms would make it look nicer.

Top
#139544 - 2005-05-13 09:14 AM Re: Need a jump start...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Thanks to Richard H. for a better solution to the loop then I originally had.

Okay here is a version that should get you started.
It will gather a list of all the .INI files in a given folder and then present them on screen for the user to make a choice.

This current code was tested using a folder named C:\CONTROL
Which had 14 .INI files in the folder.

AdminSetup.ini
Baltimore.ini
Chicago.ini
Dallas.ini
Glendale.ini
HongKong.ini
Hotel.ini
Leatherhead.ini
London.ini
LosAngeles.ini
Montreal.ini
Paris.ini
Tokyo.ini
WorkShop.ini


Here is an example of the output.

    Which configuraton file do you want to use?
      1. AdminSetup
      2. Baltimore
      3. Chicago
      4. Dallas
      5. Glendale
      6. HongKong
      7. Hotel
      8. Leatherhead
      9. London
    10. LosAngeles
    11. Montreal
    12. Paris
    13. Tokyo
    14. WorkShop

Enter a number between 1 and 14, or '99' to quit: 8
You chose the configuration file Leatherhead
 
Please let us know if this script works okay for you or if you were wanting something else.
 



Break On
Dim $SO,$Pause
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')


Dim $iIndex,$iAnswer,$sAnswer,$Choices
$Choices = Split(ChangeSettings('C:\CONTROL','*.ini'),'*')
$iAnswer=0
While Not $iAnswer
CLS "Which configuraton file do you want to use?"+@CRLF
For $iIndex = 1 To Ubound($Choices)+1
Right(" "+$iIndex,3)+". "+$Choices[$iIndex-1]+@CRLF
Next
$iIndex=$iIndex-1
@CRLF+"Enter a number between 1 and "+$iIndex+", or '99' to quit: "
GetS $sAnswer
$iAnswer=CInt($sAnswer)
If $iAnswer=99 Or ($iAnswer>0 And $iAnswer<=$iIndex)
; Valid response
Else
$iAnswer=0
Beep
Color r+/n "Invalid response - try again!" Color w/n @CRLF Sleep 2
EndIf
Loop


If $iAnswer=99
"Ok, No choice made, exiting now..."+@CRLF
Quit 0
EndIf


; Process the answer here...
"You chose the configuration file "+$Choices[$iAnswer-1]+@CRLF


Function ChangeSettings($Folder,$Type)
Dim $File
$File = Dir($Folder+'\'+$Type)
While Not @ERROR
If Not (GetFileAttr($File) & 16)
$ChangeSettings = $ChangeSettings+'*'+Left($File,-4)
EndIf
$File = Dir()
Loop
$ChangeSettings=SubStr($ChangeSettings,2)
EndFunction


 


Edited by NTDOC (2005-05-13 11:44 PM)

Top
#139545 - 2005-05-13 10:36 PM Re: Need a jump start...
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Shawn has some OLD.... kix code.. that i saved ... long ago... the old way, pre kixforms
Top
#139546 - 2005-05-13 11:12 PM Re: Need a jump start...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Thanks Bryce. Yeah, that's some OLD code alright. The above code with 4.x is much smaller.

Thanks to you Shawn though for writing that code too.
 

Top
#139547 - 2005-05-13 11:46 PM Re: Need a jump start...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Okay, updated the code again with an improved version from Richard.

I guess I only get the finder and beginning solution fee, Richard gets the Improved code fee.

 

Top
#139548 - 2005-05-16 01:23 AM Re: Need a jump start...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Here is a KiXforms version. No selection required. Choose the configuration file and then run the code called from the chosen .ini file.



Get KiXforms from here
KiXforms


Here is the code.
 
Break On
$sAppVer = '1.0 5/15/2005'
$sKiXVer = SubStr(@KIX,1,4)
$sKiXMin = '4.23'
$sKFMin = '2.4.0.45'


If $sKiXVer < $sKiXMin
$sMsg = MessageBox('This Script requires at least KiXtart '+$skiXMin,'Version Check',4112)
Quit 1
EndIf


If @ERROR Or CheckKiXformsVersion($sKFMin) < $sKFMin
$sMsg = MessageBox('This Script requires at least KiXforms '+
$sKFMin+@CRLF+'Current version is: '+CheckKiXformsVersion(),'Version Check',4112)
Quit 1
EndIf


$System = CreateObject("Kixtart.System")


;************* Form **************
$Form = $System.Form()
$Form.Icon = 19
$Form.BorderStyle = 1
$Form.BackColor = 212,208,200
$Form.Height = 250
$Form.Center
$Form.Text = "Configuration Settings"
$Form.Width = 350
;**************************************


;************* GroupBox_Selection **************
$GroupBox_Selection = $Form.Controls.GroupBox()
$GroupBox_Selection.BackColor = 212,208,200
$GroupBox_Selection.Height = 200
$GroupBox_Selection.Left = 0
$GroupBox_Selection.Text = "Select Configuration"
$GroupBox_Selection.Top = 0
$GroupBox_Selection.Width = 340
;**************************************


;************* ComboBox2 **************
$ComboBox = $GroupBox_Selection.Controls.ComboBox()
$ComboBox.DropDownWidth = 125
$ComboBox.Height = 150
$ComboBox.Left = 15
$ComboBox.Sorted = "False"
$ComboBox.Text = "Select"
$ComboBox.Top = 25
$ComboBox.Width = 121
$ComboBox.onclick = 'SelectItem()'
;**************************************


;************* Label **************
$Label = $GroupBox_Selection.Controls.Label()
$Label.Bounds = 150,25,175,100
$Label.Text = ''
$Label.Visible = 0
;**************************************


;************* Button **************
$Button = $GroupBox_Selection.Controls.Button()
$Button.Bounds = 200,160,75,25
$Button.Text = 'E&xit'
$Button.Visible = 1
$Button.onclick = "ExitClick()"
;**************************************




$Choices = Split(ChangeSettings('C:\CONTROL','*.ini'),'*')


For $iIndex = 0 To Ubound($Choices)
$ComboBox.AddItem($Choices[$iIndex])
Next


$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 0


Function SelectItem()
Dim $Msg
$Label.Text = 'The system will now be configured for '+$ComboBox.Text
$Label.Visible = 1
; Add code to read the selected .ini file and configure the system.
EndFunction


Function CheckKiXformsVersion(optional $KFMin)
Dim $KFDll,$KFVer,$objSystem,$Main
If Not $KFMin $KFMin="2.3.0.45" EndIf
$KFDll=ReadValue('HKCR\CLSID\{F89DF848-618A-46F9-8A1C-396EA442BDD3}\InprocServer32','')
If @ERROR
$CheckKiXformsVersion=@ERROR
Exit $CheckKiXformsVersion
EndIf
$KFVer=GetFileVersion($KFDll,'BinFileVersion')+GetFileVersion($KFDll,'SpecialBuild')
If @ERROR
$CheckKiXformsVersion=@ERROR
Exit $CheckKiXformsVersion
EndIf
If $KFVer < $KFMin
Exit 13
EndIf
$objSystem = CreateObject("Kixtart.System")
$Main=$objSystem.Form()
If @ERROR
$CheckKiXformsVersion=@ERROR
Exit $CheckKiXformsVersion
EndIf
$CheckKiXformsVersion=$KFVer
EndFunction


Function ChangeSettings($Folder,$Type)
Dim $File
$File = Dir($Folder+'\'+$Type)
While Not @ERROR
If Not (GetFileAttr($File) & 16)
$ChangeSettings = $ChangeSettings+'*'+Left($File,-4)
EndIf
$File = Dir()
Loop
$ChangeSettings=SubStr($ChangeSettings,2)
EndFunction


Function ExitClick()
Quit()
EndFunction


 

Top
#139549 - 2005-05-16 03:56 AM Re: Need a jump start...
xpanmanx Offline
Starting to like KiXtart

Registered: 2002-07-08
Posts: 108
Loc: St. Louis MO USA
Thank you very much NTDOC! I was hoping for a pointer in the right direction, not the complete TripTik

All I did was replace the c:\control value with @SCRIPTDIR, and pass off the result to the rest of my script.

From the first read through your code, it is obvious that you have saved me from a singular hell: While I'm sure this amounted to a minor flexing of your coding muscle, it is clearly something that would've taken me at least a couple of dozen hours to construct.

Thanks again, so very much!

Top
#139550 - 2005-05-16 03:59 AM Re: Need a jump start...
xpanmanx Offline
Starting to like KiXtart

Registered: 2002-07-08
Posts: 108
Loc: St. Louis MO USA
Ahhhhhhhhhhh now this is elegant. And again, above and beyond the call. Thank you very much for giving so much of your weekend to my cause

Sadly, my knowledge of KiXforms is very limited. I'm going to have to learn this from the ground up, but my interest will be held fast by this real-world example you've given me.

Thanks again!

Top
#139551 - 2005-05-16 05:16 AM Re: Need a jump start...
xpanmanx Offline
Starting to like KiXtart

Registered: 2002-07-08
Posts: 108
Loc: St. Louis MO USA
Whoo hoo! Got it goin' on with KiXforms.

I copied my script verbatim into NTDOC's KiXforms code, where his comment indicated that I should.

I even learned enough (Baby steps, Bob, baby steps...) to change some simple UI settings in NTDOC's code.

As far as passing the INI location through to my original code, well, I monkeyed around with @SCRIPTDIR for a while, but it didn't work correctly after the script was packaged, then @SCRIPTDIR becomes the user's temporary folder!

So I used KiXscripts Editor's $EXEParams variable, instead. I added a quick syntax check and VOILA!

Thanks again, NTDOC. You're a lifesaver.

Here's my 1st production version. I hope you can figure out where NTDOC's code stops, and mine begins

Code:
;Turn on the break key.  If this command is not present, and the operator halts execution, the operator will be forcibly logged off.
Break on
Color c+/n
? @scriptname
$dummy = SetOption('wrapateol','on')
;dummy = SetOption('explicit','on')

@crlf + @crlf

$dummy = SetTitle (@scriptname)

;===============================================================================================
;Syntax check
If $exeparams = ''
Color r+/n
? 'Syntax: site configuration.exe [path to inis]'
? 'example: c:\site configuration.exe c:\program files\site configuration'
Color c+/n
Beep
Sleep 5
Exit
EndIf
;===============================================================================================

$sAppVer = '1.0 5/15/2005'
$sKiXVer = SubStr(@KIX,1,4)
$sKiXMin = '4.23'
$sKFMin = '2.4.0.45'

If $sKiXVer < $sKiXMin
$sMsg = MessageBox('This Script requires at least KiXtart '+$skiXMin,'Version Check',4112)
Quit 1
EndIf

If @ERROR OR CheckKiXformsVersion($sKFMin) < $sKFMin
$sMsg = MessageBox('This Script requires at least KiXforms '+
$sKFMin+@CRLF+'Current version is: '+CheckKiXformsVersion(),'Version Check',4112)
Quit 1
EndIf

$System = CreateObject("Kixtart.System")


;************* Form **************
$Form = $System.Form()
$Form.Icon = 19
$Form.BorderStyle = 1
$Form.BackColor = 212,208,200
$Form.Height = 250
$Form.Center
$Form.Text = "Site Configuration"
$Form.Width = 350
;**************************************


;************* GroupBox_Selection **************
$GroupBox_Selection = $Form.Controls.GroupBox()
$GroupBox_Selection.BackColor = 212,208,200
$GroupBox_Selection.Height = 200
$GroupBox_Selection.Left = 0
$GroupBox_Selection.Text = ""
$GroupBox_Selection.Top = 0
$GroupBox_Selection.Width = 340
;**************************************


;************* ComboBox2 **************
$ComboBox = $GroupBox_Selection.Controls.ComboBox()
$ComboBox.DropDownWidth = 125
$ComboBox.Height = 150
$ComboBox.Left = 15
$ComboBox.Sorted = "True"
$ComboBox.Text = "Select a site"
$ComboBox.Top = 25
$ComboBox.Width = 121
$ComboBox.onclick = 'SelectItem()'
;**************************************


;************* Label **************
$Label = $GroupBox_Selection.Controls.Label()
$Label.Bounds = 150,25,175,100
$Label.Text = ''
$Label.Visible = 0
;**************************************


;************* Button **************
$Button = $GroupBox_Selection.Controls.Button()
$Button.Bounds = 200,160,75,25
$Button.Text = '&Ok'
$Button.Visible = 1
$Button.onclick = "ExitClick()"
;**************************************




$Choices = Split(ChangeSettings($EXEParams,'\*.ini'),'*')


For $iIndex = 0 To Ubound($Choices)
$ComboBox.AddItem($Choices[$iIndex])
Next


$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 0


Function SelectItem()
Dim $Msg
$Label.Text = 'The system will now be configured for '+$ComboBox.Text + '. Please click Ok when DONE is displayed.'
$Label.Visible = 1
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================


$location_ini=$EXEParams + '\' + $ComboBox.Text + '.ini'

CLS

Gosub READ_LOCATION_INI

Gosub IE_CONFIGURE

Gosub FWC_CONFIGURE

If $windows_default_printer <> 'FALSE' Gosub PRINTER_CONFIGURE EndIf

? ? Color B/W+ 'Done.' Color c+/n ?

Return

;===============================================================================================
:READ_LOCATION_INI
Color y/n ? '======================================' Color c+/n

? 'Reading ' + $location_ini
? '---'

If NOT Exist ($location_ini)
Color r+/n
? $location_ini + ' could not be found. Exiting.'
Color c+/n
Beep
Exit
EndIf

$location_name = ReadProfileString($location_ini,'location information','location name')

$ie_proxy_enable = ReadProfileString($location_ini,'ie proxy server settings','enable (true or false)')
$ie_automatically_detect_settings = ReadProfileString($location_ini,'ie proxy server settings','automatically detect settings (true or false)')
$ie_use_automatic_configuration_script = Ucase(ReadProfileString($location_ini,'ie proxy server settings','use automatic configuration script (url or false)'))
$ie_use_a_proxy_server_for_your_lan = Ucase(ReadProfileString($location_ini,'ie proxy server settings','use a proxy server for your lan (name:port or false)'))
$ie_do_not_use_proxy_server_for_addresses_beginning_with = Ucase(ReadProfileString($location_ini,'ie proxy server settings','do not use proxy server for addresses
beginning with ( and/or urls seperated by commas)'))

$fwc_enable = ReadProfileString($location_ini,'fwc settings','enable (true or false)')
$fwc_manual_isa_server_name = Ucase(ReadProfileString($location_ini,'fwc settings','manual isa server name (fq server name or ip or false)'))
$fwc_enable_browser_configuration = ReadProfileString($location_ini,'fwc settings','enable browser configuration (true or false)')

$windows_default_printer = Ucase(ReadProfileString($location_ini,'printer settings','default printer (local name or unc or false)'))

? 'location_name=' + $location_name
? 'ie_proxy_enable=' + $ie_proxy_enable
? 'ie_automatically_detect_settings=' + $ie_automatically_detect_settings
? 'ie_use_automatic_configuration_script=' + $ie_use_automatic_configuration_script
? 'ie_use_a_proxy_server_for_your_lan=' + $ie_use_a_proxy_server_for_your_lan
? 'ie_do_not_use_proxy_server_for_addresses_beginning_with=' + $ie_do_not_use_proxy_server_for_addresses_beginning_with

? 'fwc_enable=' + $fwc_enable
? 'fwc_manual_isa_server_name=' + $fwc_manual_isa_server_name
? 'fwc_enable_browser_configuration=' + $fwc_enable_browser_configuration

? 'windows_default_printer=' + $windows_default_printer

Color y/n ? '======================================' Color c+/n

Return
;===============================================================================================

;===============================================================================================
:IE_CONFIGURE
:IE_CONFIGURE_LOCAL_MACHINE
? '...configuring local machine IE proxy server settings.'

If $ie_proxy_enable = 'false' $dummy = DelValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings','proxyenable')
Else
$dummy = WriteValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings','proxyenable','1','reg_dword')
EndIf

If $ie_use_a_proxy_server_for_your_lan = 'false' $dummy = DelValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings','proxyserver')
Else
$dummy = WriteValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings','proxyserver',$ie_use_a_proxy_server_for_your_lan,'reg_sz')
EndIf

If $ie_automatically_detect_settings = 'false'
$dummy = WriteValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings\connections','defaultconnectionsettings',
'3c000000020000000100000000000000070000003c6c6f63616c3e0000000000000000000000000000000000000000000000000000000000000000','reg_binary')
$dummy = WriteValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings\connections','savedlegacysettings',
'3c000000040000000100000000000000070000003c6c6f63616c3e0000000000000000000000000000000000000000000000000000000000000000','reg_binary')
Else
$dummy = WriteValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings\connections','defaultconnectionsettings',
'3c000000030000000900000000000000070000003c6c6f63616c3e0000000001000000000000000000000000000000000000000000000000000000','reg_binary')
$dummy = WriteValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings\connections','savedlegacysettings',
'3c000000070000000900000000000000070000003c6c6f63616c3e0000000001000000000000000000000000000000000000000000000000000000','reg_binary')
EndIf

If $ie_use_automatic_configuration_script = 'false' $dummy = DelValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings','autoconfigurl')
Else
$dummy = WriteValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings','autoconfigurl',$ie_use_automatic_configuration_script,'reg_sz')
EndIf

$dummy=WriteValue('hkey_local_machine\software\microsoft\windows\currentversion\internet settings','proxyoverride',$ie_do_not_use_proxy_server_for_addresses_beginning_with,'reg_sz')

;current user IE proxy server settings
:IE_CONFIGURE_CURRENT_USER
? '...configuring current user IE Proxy Server settings.'

If $ie_proxy_enable = 'false' $dummy = DelValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','proxyenable')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','proxyenable','1','reg_dword')
EndIf

If $ie_use_a_proxy_server_for_your_lan = 'false' $dummy = DelValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','proxyserver')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','proxyserver',$ie_use_a_proxy_server_for_your_lan,'reg_sz')
EndIf

If $ie_automatically_detect_settings = 'false'
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings\connections','defaultconnectionsettings',
'3c000000020000000100000000000000070000003c6c6f63616c3e0000000000000000000000000000000000000000000000000000000000000000','reg_binary')
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings\connections','savedlegacysettings',
'3c000000040000000100000000000000070000003c6c6f63616c3e0000000000000000000000000000000000000000000000000000000000000000','reg_binary')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings\connections','defaultconnectionsettings',
'3c000000030000000900000000000000070000003c6c6f63616c3e0000000001000000000000000000000000000000000000000000000000000000','reg_binary')
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings\connections','savedlegacysettings',
'3c000000070000000900000000000000070000003c6c6f63616c3e0000000001000000000000000000000000000000000000000000000000000000','reg_binary')
EndIf

If $ie_use_automatic_configuration_script = 'false' $dummy = DelValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','autoconfigurl')
Else
$dummy = WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','autoconfigurl',$ie_use_automatic_configuration_script,'reg_sz')
EndIf

$dummy=WriteValue('hkey_current_user\software\microsoft\windows\currentversion\internet settings','proxyoverride',$ie_do_not_use_proxy_server_for_addresses_beginning_with,'reg_sz')

Color y/n ? '======================================' Color c+/n

Return
;===============================================================================================

;===============================================================================================
:FWC_CONFIGURE
? '...configuring ISA Server 2004 Firewall Client.'

If $fwc_enable = 'FALSE'
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" disable'
Color y/n ? '======================================' Color c+/n
Return
Else
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" enable'
EndIf

If $fwc_enable = 'TRUE' AND $fwc_manual_isa_server_name = 'FALSE'
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" SetAutoDetectServer'
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" TestAutoDetect'
Else
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" setmanualserver /server:' + $fwc_manual_isa_server_name
EndIf

If $fwc_enable_browser_configuration = 'FALSE' Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" disablebrowserconfig'
Else
Shell '"c:\program files\microsoft firewall client 2004\fwctool.exe" enablebrowserconfig'
EndIf

Color y/n ? '======================================' Color c+/n

Return
;===============================================================================================

;===============================================================================================
:PRINTER_CONFIGURE
? '...setting Windows default printer.'

$dummy = AddPrinterConnection($windows_default_printer)
$dummy = SetDefaultPrinter($windows_default_printer)

Color y/n ? '======================================' Color c+/n

Return
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
;===============================================================================================
EndFunction


Function CheckKiXformsVersion(optional $KFMin)
Dim $KFDll,$KFVer,$objSystem,$Main
If NOT $KFMin $KFMin="2.3.0.45" EndIf
$KFDll=ReadValue('HKCR\CLSID\{F89DF848-618A-46F9-8A1C-396EA442BDD3}\InprocServer32','')
If @ERROR
$CheckKiXformsVersion=@ERROR
Exit $CheckKiXformsVersion
EndIf
$KFVer=GetFileVersion($KFDll,'BinFileVersion')+GetFileVersion($KFDll,'SpecialBuild')
If @ERROR
$CheckKiXformsVersion=@ERROR
Exit $CheckKiXformsVersion
EndIf
If $KFVer < $KFMin
Exit 13
EndIf
$objSystem = CreateObject("Kixtart.System")
$Main=$objSystem.Form()
If @ERROR
$CheckKiXformsVersion=@ERROR
Exit $CheckKiXformsVersion
EndIf
$CheckKiXformsVersion=$KFVer
EndFunction


Function ChangeSettings($Folder,$Type)
Dim $File
$File = Dir($Folder+'\'+$Type)
While NOT @ERROR
If NOT (GetFileAttr($File) & 16)
$ChangeSettings = $ChangeSettings+'*'+Left($File,-4)
EndIf
$File = Dir()
Loop
$ChangeSettings=SubStr($ChangeSettings,2)
EndFunction

Function ExitClick()
Quit()
EndFunction


Top
#139552 - 2005-05-16 09:23 AM Re: Need a jump start...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
xpanmanx, You're quite welcome for the code.

Couple other issues/questions though.

This looks almost like you're expecting this to launch during a logon script. You're mixing code that would show on a DOS CONSOLE window which is one of the reasons for using KiXforms is to do away with that stuff.

You should normally not be showing anything except what can be seen in a GUI format within KiXforms using this method.
    Questions:
  • 1. Do you want the Admins to be able to make choices?
    (if so that can be done within KiXforms as well)

  • 2. If you want the Admin to make a choice then why have different .ini files?

  • 3. Why would you have the .ini configuration files in the same folder as the script unless they are isolated from other .ini files? Currently you're not filtering out specific ones so ALL .ini files would show up in the list.


Personally I would choose one way or the other.
Either DO NOT give the Admin a choice beyond picking which configuration (then have the script automatically perform all tasks listed in the ini file)
OR - Setup the KiXform to show/allow the choices that will be possible to change.

In any case I would remove or silence all code that attempts to ouput to a DOS window and setup the form to run from a shortcut on their desktop and use a COMMON folder on all systems.

Also, I would use a registry read for the firewall and other programs and not HARD CODE the path. If you need help or suggestions further in that area please let us know.

Good luck and best wishes.
 

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1636 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.073 seconds in which 0.029 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