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