fork(1) download
  1. 'On Error Resume Next
  2. ' main chunk of code originally written by Ian Diston
  3. ' code rewritten by MWJ - work in progress
  4.  
  5.  
  6. set objShell = WScript.CreateObject( "WScript.Shell" )
  7. set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
  8. const HKCU = &H80000001
  9. strComputer = "."
  10.  
  11.  
  12. 'Calls the isMember function with the specified group to check if current user is a member
  13. If isMember("APP_Smartview") Then
  14. ' clean up any legacy registry key values, then create correct ones re: smartview
  15. FunRegKeysDelete
  16. FunRegKeysCreate
  17. Else
  18. 'Call funRegKeys to delete any keys not required - as user is NOT a member of the Smartview app group
  19. FunRegKeysDelete
  20. End If
  21.  
  22.  
  23.  
  24. Function IsMember(groupName)
  25. ' function checks to see if the passed group name contains the current user. Returns True or False
  26. Set groupListDict = CreateObject("Scripting.Dictionary")
  27. groupListDict.CompareMode = 1
  28. ADSPath = EnvString("userdomain") & "/" & EnvString("username")
  29. Set userPath = GetObject("WinNT://" & ADSPath & ",user")
  30. For Each listGroup in userPath.Groups
  31. groupListDict.Add listGroup.Name, "-"
  32. Next
  33. IsMember = CBool(groupListDict.Exists(groupName))
  34. End Function
  35.  
  36.  
  37.  
  38. Function EnvString(variable)
  39. ' function returns a particular environment variable's value.
  40. ' for example, if you use EnvString("username"), it would return the value of %username%.
  41. variable = "%" & variable & "%"
  42. EnvString = objShell.ExpandEnvironmentStrings(variable)
  43. End Function
  44.  
  45.  
  46.  
  47. Function FunRegKeysDelete
  48. strKeyPath = "Software\Microsoft\Office\11.0\Excel\Options"
  49. objReg.EnumValues HKCU, strKeyPath, arrValueNames, arrValueTypes
  50.  
  51. For i = 0 to UBound(arrValueNames)
  52. If Left (arrValueNames(i),4) = "OPEN" then
  53. objReg.GetStringValue HKCU, strKeyPath, arrValueNames(i), strValue
  54. If strValue = """C:\Oracle\SmartView\Bin\HsTbar.xla""" then
  55. strBlank = ""
  56. objReg.SetStringValue HKCU, strKeyPath, arrValueNames(i), strBlank
  57. Else
  58. 'Do nothing
  59. End If
  60. Else
  61. 'Do nothing
  62. End If
  63. Next
  64.  
  65.  
  66. ' portion of code below is written to delete the hyperion.commonadin registry key and all sub-keys for the 4x relevant office apps
  67. ' keys for deletion are listed below:
  68. strKeyPathtoDELETE1 = "Software\Microsoft\Office\Excel\Addins\Hyperion.CommonAddin"
  69. strKeyPathtoDELETE2 = "Software\Microsoft\Office\PowerPoint\Addins\Hyperion.CommonAddin"
  70. strKeyPathtoDELETE3 = "Software\Microsoft\Office\Word\Addins\Hyperion.CommonAddin"
  71. strKeyPathtoDELETE4 = "Software\Microsoft\Office\Outlook\Addins\Hyperion.CommonAddin"
  72.  
  73. ' delete the keys above using a code loop to cycle through them
  74. for z = 1 to 4
  75. strKeyPathtoDELETE = strKeyPathtoDELETE(z)
  76. DeleteSubkeys HKCU, strKeyPathtoDELETE
  77. next
  78.  
  79. Sub DeleteSubkeys(HKEY_LOCAL_MACHINE, strKeyPathtoDELETE)
  80. objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPathtoDELETE, arrSubkeys
  81. If IsArray(arrSubkeys) Then
  82. For Each strSubkey In arrSubkeys
  83. DeleteSubkeys HKEY_LOCAL_MACHINE, strKeyPathtoDELETE & "\" & strSubkey
  84. Next
  85. End If
  86. objReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPathtoDELETE
  87. End Sub
  88.  
  89. ' end of the "FunRegKeysDelete" function
  90. End Function
  91.  
  92.  
  93.  
  94.  
  95. Function FunRegKeysCreate
  96. 'This function creates the registry keys depending on Group Membership.
  97. strKeyPath1 = "Software\Microsoft\Office\11.0\Excel\Options"
  98. objReg.EnumValues HKCU, strKeyPath1, arrValueNames, arrValueTypes
  99.  
  100. intCount = 0
  101. For i = 0 to UBound(arrValueNames)
  102. If Left (arrValueNames(i),4) = "OPEN" then
  103. intCount = intCount + 1
  104. 'msgbox arrValueNames(i) & "-" & intCount
  105. Else
  106. 'Do nothing
  107. End If
  108. Next
  109.  
  110. If intCount = 0 then
  111. 'No OPEN key found so create first OPEN key
  112. strHSTbar = """C:\Oracle\SmartView\Bin\HsTbar.xla"""
  113. objReg.SetStringValue HKCU, strKeyPath1, "OPEN", strHSTbar
  114. Else
  115. 'OPEN found so create next OPEN value
  116. strOpenValue = intcount
  117. 'MsgBox "OPEN" & strOpenValue
  118. strHSTbar = """C:\Oracle\SmartView\Bin\HsTbar.xla"""
  119. objReg.SetStringValue HKCU, strKeyPath1, "OPEN" & strOpenValue, strHSTbar
  120. End If
  121.  
  122.  
  123. ' section of code inserted to handle Hyperion.commonAddin registry key which is added to the addins for each office application respectively.
  124. ' additional key paths to have registry entries for Hyperion Toolbar added
  125. strKeyPath2 = "Software\Microsoft\Office\Excel\Addins\Hyperion.CommonAddin"
  126. strKeyPath3 = "Software\Microsoft\Office\PowerPoint\Addins\Hyperion.CommonAddin"
  127. strKeyPath4 = "Software\Microsoft\Office\Word\Addins\Hyperion.CommonAddin"
  128. strKeyPath5 = "Software\Microsoft\Office\Outlook\Addins\Hyperion.CommonAddin"
  129. ' additional registry values for hyperion toolbar registry key entries - for the above regkey locations
  130. strFriendlyName = """Oracle® Hyperion Smart View for Office, Fusion Edition"""
  131. strDescription = """Oracle® Hyperion Smart View for Office, Fusion Edition"""
  132. strDWORDLoadBehaviour = "00000000"
  133. strDWORDCommandLineSafe = "00000000"
  134.  
  135. ' enumerate registry values re: checking for the appropriate entries for the hyperion toolbar for each office application
  136. objReg.EnumValues HKCU, strKeyPath2, arrValueNames2, arrValueTypes2
  137. objReg.EnumValues HKCU, strKeyPath3, arrValueNames3, arrValueTypes3
  138. objReg.EnumValues HKCU, strKeyPath4, arrValueNames4, arrValueTypes4
  139. objReg.EnumValues HKCU, strKeyPath5, arrValueNames5, arrValueTypes5
  140.  
  141.  
  142. for x = 2 to 5
  143. ' main loop to cycle through the repeated code for each of the above registry keys
  144.  
  145. intCount = 0
  146. ' check the 2nd array re: excel toolbar registry key presence, else create them
  147. For i = 0 to UBound(arrValueNames(x))
  148. If Left (arrValueNames(x)(i),13) = "LoadBehaviour" then
  149. intCount = intCount + 1
  150. 'msgbox arrValueNames(x)(i) & "-" & intCount
  151. Else
  152. 'Do nothing
  153. End If
  154. Next
  155.  
  156. If intCount = 0 then
  157. 'No LoadBehaviour key found so create relevant keys for the toolbar
  158. objReg.SetStringValue HKCU, strKeyPath(x), "FriendlyName", strFriendlyName
  159. objReg.SetStringValue HKCU, strKeyPath(x), "Description", strDescription
  160. objReg.SetDWORDValue HKCU, strKeyPath(x), "LoadBehaviour", strDWORDLoadBehaviour
  161. objReg.SetDWORDValue HKCU, strKeyPath(x), "CommandLineSafe", strDWORDCommandLineSafe
  162. Else
  163. ' move along - nothing to see here
  164. End If
  165.  
  166. ' end of the code loop
  167. next
  168.  
  169.  
  170. ' end of the "FunRegKeysCreate" function
  171. End Function
  172.  
  173.  
  174.  
  175.  
  176. ' Script Clean up Section
  177. Set objShell = Nothing
  178. Set objReg = Nothing
  179.  
  180.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty