add-registry-values-20040313
[openafs.git] / src / WINNT / install / NSIS / OpenAFS.nsi
index 6be493f..268e743 100644 (file)
@@ -437,6 +437,15 @@ VIAddVersionKey "PrivateBuild" "Checked/Debug"
   ;Only useful for BZIP2 compression
   !insertmacro MUI_RESERVEFILE_LANGDLL
   
+;--------------------------------
+; User Variables
+
+var REG_SUB_KEY
+var REG_VALUE
+var REG_DATA_1
+var REG_DATA_2
+var REG_DATA_3
+
 
 ;--------------------------------
 ;Installer Sections
@@ -614,9 +623,12 @@ skipremove:
   Delete "$INSTDIR\Common\service.exe"
 
   ; Daemon entries
-  WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon" "(Default)" ""
+  WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon" "" ""
+  WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "ProviderPath" "$INSTDIR\Client\Program\afslogon.dll"
+  WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "AuthentProviderPath" "$INSTDIR\Client\Program\afslogon.dll"
   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "AuthentProviderPath" "$INSTDIR\Client\Program\afslogon.dll"
   WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "Class" 2
+  WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "VerboseLogging" 10
   ReadINIStr $R0 $1 "Field 7" "State"
   ReadINIStr $R1 $1 "Field 9" "State"
   ; Complicated way to do $R1 = ($R1 *2) + $R0
@@ -625,7 +637,19 @@ skipremove:
   WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "LogonOptions" $R1
   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "LogonScript" "$INSTDIR\Client\Program\afscreds.exe -:%s -x"
   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "Name" "OpenAFSDaemon"
-  WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "ProviderPath" "$INSTDIR\Client\Program\afslogon.dll"
+
+  strcpy $REG_SUB_KEY "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" 
+  strcpy $REG_VALUE   "DependOnGroup" 
+  strcpy $REG_DATA_1  "PNP_TDI"
+  strcpy $REG_DATA_2  ""
+  strcpy $REG_DATA_3  ""
+  Call RegWriteMultiStr
+  strcpy $REG_SUB_KEY "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" 
+  strcpy $REG_VALUE   "DependOnService" 
+  strcpy $REG_DATA_1  "Tcpip"
+  strcpy $REG_DATA_2  "NETBIOS"
+  strcpy $REG_DATA_3  "NetBT"
+  Call RegWriteMultiStr
 
   ;Write cell name
   ReadINIStr $R0 $1 "Field 2" "State"
@@ -638,7 +662,10 @@ skipremove:
   WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "UseDNS" 1
   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "NetbiosName" "AFS"
   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "MountRoot" "/afs"
-  WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "RxMaxMTU" 1200
+  WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "RxMaxMTU" 1260
+  WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "IsGateway" 0
+  WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "HideDotFiles" 1
+  WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "TruncateNetbios" "on"
 !IFDEF DEBUG
   WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "NoFindLanaByName" 1
 !ENDIF
@@ -3428,3 +3455,87 @@ MakeClientSelected:
 end:
 FunctionEnd
 
+Function RegWriteMultiStr
+!define HKEY_CLASSES_ROOT        0x80000000
+!define HKEY_CURRENT_USER        0x80000001
+!define HKEY_LOCAL_MACHINE       0x80000002
+!define HKEY_USERS               0x80000003
+!define HKEY_PERFORMANCE_DATA    0x80000004
+!define HKEY_PERFORMANCE_TEXT    0x80000050
+!define HKEY_PERFORMANCE_NLSTEXT 0x80000060
+!define HKEY_CURRENT_CONFIG      0x80000005
+!define HKEY_DYN_DATA            0x80000006
+
+!define KEY_QUERY_VALUE          0x0001
+!define KEY_SET_VALUE            0x0002
+!define KEY_CREATE_SUB_KEY       0x0004
+!define KEY_ENUMERATE_SUB_KEYS   0x0008
+!define KEY_NOTIFY               0x0010
+!define KEY_CREATE_LINK          0x0020
+
+!define REG_NONE                 0
+!define REG_SZ                   1
+!define REG_EXPAND_SZ            2
+!define REG_BINARY               3
+!define REG_DWORD                4
+!define REG_DWORD_LITTLE_ENDIAN  4
+!define REG_DWORD_BIG_ENDIAN     5
+!define REG_LINK                 6
+!define REG_MULTI_SZ             7
+
+!define RegCreateKey             "Advapi32::RegCreateKeyA(i, t, *i) i"
+!define RegSetValueEx            "Advapi32::RegSetValueExA(i, t, i, i, i, i) i"
+!define RegCloseKey              "Advapi32::RegCloseKeyA(i) i"
+
+  SetPluginUnload alwaysoff
+  ; Create a buffer for the multi_sz value
+  System::Call "*(&t${NSIS_MAX_STRLEN}) i.r1"
+  ; Open/create the registry key
+  System::Call "${RegCreateKey}(${HKEY_LOCAL_MACHINE}, '$REG_SUB_KEY', .r0) .r9"
+  ; Failed?
+  IntCmp $9 0 write
+    MessageBox MB_OK|MB_ICONSTOP "Can't create registry key! ($9)"
+    Goto noClose
+
+  write:
+    ; Fill in the buffer with our strings
+    StrCpy $2 $1                            ; Initial position
+
+    StrLen $9 '$REG_DATA_1'                 ; Length of first string
+    IntOp $9 $9 + 1                         ; Plus null
+    System::Call "*$2(&t$9 '$REG_DATA_1')"  ; Place the string
+    IntOp $2 $2 + $9                        ; Advance to the next position
+
+    StrCmp '$REG_DATA_2' "" terminate
+    StrLen $9 '$REG_DATA_2'                 ; Length of second string
+    IntOp $9 $9 + 1                         ; Plus null
+    System::Call "*$2(&t$9 '$REG_DATA_2')"  ; Place the string
+    IntOp $2 $2 + $9                        ; Advance to the next position
+
+    StrCmp '$REG_DATA_3' "" terminate
+    StrLen $9 '$REG_DATA_3'                 ; Length of third string
+    IntOp $9 $9 + 1                         ; Plus null
+    System::Call "*$2(&t$9 '$REG_DATA_3')"  ; Place the string
+    IntOp $2 $2 + $9                        ; Advance to the next position
+
+  terminate:
+    System::Call "*$2(&t1 '')"              ; Place the terminating null
+    IntOp $2 $2 + 1                         ; Advance to the next position
+
+    ; Create/write the value
+    IntOp $2 $2 - $1                        ; Total length
+    System::Call "${RegSetValueEx}(r0, '$REG_VALUE', 0, ${REG_MULTI_SZ}, r1, r2) .r9"
+    ; Failed?
+    IntCmp $9 0 done
+      MessageBox MB_OK|MB_ICONSTOP "Can't set key value! ($9)"
+      Goto done
+
+  done:
+    ; Close the registry key
+    System::Call "${RegCloseKey}(r0)"
+
+noClose:
+  ; Clear the buffer
+  SetPluginUnload manual
+  System::Free $1
+FunctionEnd
\ No newline at end of file