Devon, my personal opinion is to avoid WSH when possible, just because I have run into cases wehre I used a vbscript custom action in an MSI package, and the WSH is unavailable [1] to the Windows Installer. Since I ran that, if I think I might need to use this cool new thing I figured out how to do with vbscript in an MSI, then I try to use WMI or other methods, even if WSH exposes them more easily. But that's my personal preference, and I am by no means a scripting guru :)
Rich [1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/set up/scripts.asp: "Note The installer runs script custom actions directly and does not use the Windows Script Host. The WScript object cannot be used inside a script custom action because this object is provided by the Windows Script Host. Objects in the Windows Script Host object model can only be used in custom actions if Windows Script Host is installed on the computer by creating new instances of the object, with a call to CreateObject, and providing the ProgId of the object (for example "WScript.Shell"). Depending on the type of script custom action, access to some objects and methods of the Windows Script Host object model may be denied for security reasons." ----------------------------------------------------------------------- Rich Milburn MCSE, Microsoft MVP - Directory Services Sr Network Analyst, Field Platform Development Applebee's International, Inc. 4551 W. 107th St Overland Park, KS 66207 913-967-2819 ---------------------------------------------------------------------- "I am always doing that which I can not do, in order that I may learn how to do it." - Pablo Picasso -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Harding, Devon Sent: Monday, October 17, 2005 11:45 AM To: [email protected] Subject: RE: [ActiveDir] Kix to VBS Which method is preferred, WSH or WMI? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alain Lissoir Sent: Monday, October 17, 2005 12:01 PM To: [email protected] Subject: RE: [ActiveDir] Kix to VBS Look at http://www.lissware.net, Volume 1, Sample 1.01 to 1.25 - WSHScript.vbs, which uses a series of functions. In this list of functions, you will find two generic routines to play with: ReadRegistryFunction.vbs and WriteRegistryFunction.vbs. With these two, you are all set. I reproed the ReadRegistry one below. Note that from the WSH object model, RegWrite method does not support REG_MULTI_SZ. If you need to update REG_MULTI_SZ, you need to use the WMI model. For this see http://www.lissware.net, Vol 2, Sample 3.03 to 3.09 - WMIRegistry.wsf (Second code exerpt below). HTH. ' Author: Alain Lissoir ([EMAIL PROTECTED]) ' ' ISBN 1555582664 - Understanding WMI Scripting (Digital Press) ' ISBN 1555582990 - Leveraging WMI Scripting (Digital Press) ' WSH Technique ------------------------------------------------------------------------ ---- -------------------- Private Function ReadRegistry (objFileName, strKeyName, KeyValueName, strRegType) Dim strRegKey Dim varRegKeyValue() Dim intIndice Dim strTempValue On Error Resume Next strRegKey = strKeyName & "\" & KeyValueName WriteToFile objFileName, "** Reading registry '" & strRegKey & "'(" & strRegType & ")." strTempValue = WshShell.RegRead (strRegKey) If Err.Number Then ErrorHandler objFileName, "ReadRegistry", Err, boolErrorPopup Exit Function End If Select Case strRegType Case "REG_BINARY" ReDim varRegKeyValue(Ubound(strTempValue)) For intIndice = 0 to Ubound(strTempValue) varRegKeyValue (intIndice) = "&h" & Right("00" & Hex(strTempValue(intIndice)), 2) WriteToFile objFileName, _ strRegKey & "(" & UCase(strRegType) & ") -> " & varRegKeyValue(intIndice) Next Case "REG_DWORD" ReDim varRegKeyValue(0) varRegKeyValue(0) = "&h" & Hex (strTempValue) WriteToFile objFileName, _ strRegKey & "(" & UCase(strRegType) & ") -> " & varRegKeyValue(0) Case "REG_MULTI_SZ" ReDim varRegKeyValue(Ubound(strTempValue)) For intIndice = 0 to Ubound(strTempValue) varRegKeyValue (intIndice) = strTempValue(intIndice) WriteToFile objFileName, _ strRegKey & "(" & UCase(strRegType) & ") -> " & varRegKeyValue(intIndice) Next Case "REG_EXPAND_SZ" ReDim varRegKeyValue(0) varRegKeyValue(0) = WshShell.ExpandEnvironmentStrings (strTempValue) WriteToFile objFileName, _ strRegKey & "(" & UCase(strRegType) & ") -> " & varRegKeyValue(0) Case Else ReDim varRegKeyValue(0) varRegKeyValue(0) = strTempValue WriteToFile objFileName, _ strRegKey & "(" & UCase(strRegType) & ") -> " & varRegKeyValue(0) End Select ReadRegistry = varRegKeyValue End Function ' WMI technique ---------------------------------------------------------------------- Select Case intKeyType Case REG_SZ intRC = objWMIClass.SetStringValue (intHiveType, _ strBaseKey, _ strKeyName, _ varKeyNameValue) Case REG_MULTI_SZ intRC = objWMIClass.SetMultiStringValue (intHiveType, _ strBaseKey, _ strKeyName, _ varKeyNameValue) Case REG_EXPAND_SZ intRC = objWMIClass.SetExpandedStringValue (intHiveType, _ strBaseKey, _ strKeyName, _ varKeyNameValue) Case REG_BINARY intRC = objWMIClass.SetBinaryValue (intHiveType, _ strBaseKey, _ strKeyName, _ varKeyNameValue) Case REG_DWORD intRC = objWMIClass.SetDWORDValue (intHiveType, _ strBaseKey, _ strKeyName, _ varKeyNameValue) End Select -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Harding, Devon Sent: Monday, October 17, 2005 8:25 AM To: [email protected] Subject: RE: [ActiveDir] Kix to VBS Could I add multiple reg key changes to this vbs? I would have to define a new sPath at the end right? -Devon -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Almeida Pinto, Jorge de Sent: Friday, October 14, 2005 5:51 PM To: [email protected]; [email protected] Subject: RE: [ActiveDir] Kix to VBS Hi, Try the following: Cheers, jorge 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk /wmi/enumvalues_method_in_class_stdregprov.asp ########################### Const HKCU = &H80000001 Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\defau lt:StdRegProv") sPath = "Software\IXOS" On Error Resume Next sKeyExist = False oReg.EnumKey HKCU, sPath, arrSubKeys For Each sSubKey In arrSubKeys If UCase(sSubKey) = "IXOS_ARCHIVE" Then sKeyExist = True Exit For End If Next Set sSubKey = Nothing Set arrSubKeys = Nothing If sKeyExist = True Then sPath = "Software\IXOS\IXOS_ARCHIVE\Viewer\Printing" On Error Resume Next oReg.EnumKey HKCU, sPath, arrSubKeys sKeyExist = False For Each sSubKey In arrSubKeys If UCase(sSubKey) = "FAX" Then sKeyExist = True Exit For End If Next Set sSubKey = Nothing Set arrSubKeys = Nothing If sKeyExist = False Then oReg.CreateKey HKCU, sPath & "\FAX" oReg.SetDWORDValue HKCU, sPath & "\FAX", "PaperSize", 1 Else On Error Resume Next oReg.EnumValue HKCU, sPath, arrValueNames, arrValueTypes sValueExist = False For Each sValue In arrValueNames If sValue = "PaperSize" Then sValueExist = True Exit For End If Next Set sValue = Nothing Set arrValueNames = Nothing Set arrValueTypes = Nothing If sValueExist = True Then oReg.GetDWORDValue HKCU, sPath & "\FAX", "PaperSize", MYValueData If MYValueData <> "1" Then oReg.SetDWORDValue HKCU, sPath & "\FAX", "PaperSize", 1 End If Else oReg.SetDWORDValue HKCU, sPath & "\FAX", "PaperSize", 1 End If End If End If ########################### ________________________________ From: [EMAIL PROTECTED] on behalf of Harding, Devon Sent: Fri 10/14/2005 7:48 PM To: [email protected] Subject: [ActiveDir] Kix to VBS I'm having a tough time converting this kix script to ..vbs. Any Ideas? ; This change will fix an IXOS problem where the default paper size is A4 instead of Letter If KeyExist("HKCU\Software\IXOS\IXOS_ARCHIVE") = 1 If KeyExist("HKCU\Software\IXOS\IXOS_ARCHIVE\Viewer\Printing\FAX") = 0 AddKey("HKCU\Software\IXOS\IXOS_ARCHIVE\Viewer\Printing\FAX") EndIf If ReadValue("HKCU\Software\IXOS\IXOS_ARCHIVE\Viewer\Printing\FAX","PaperSi ze") <> 1 WriteValue("HKCU\Software\IXOS\IXOS_ARCHIVE\Viewer\Printing\FAX","PaperS ize","1","reg_dword") EndIf EndIf Devon Harding Windows Systems Engineer Southern Wine & Spirits - BSG 954-602-2469 ________________________________ __________________________________ This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use or distribution of the information included in the message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank You. This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. List info : http://www.activedir.org/List.aspx List FAQ : http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/List.aspx List FAQ : http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/List.aspx List FAQ : http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/List.aspx List FAQ : http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ -------APPLEBEE'S INTERNATIONAL, INC. CONFIDENTIALITY NOTICE------- PRIVILEGED / CONFIDENTIAL INFORMATION may be contained in this message or any attachments. This information is strictly confidential and may be subject to attorney-client privilege. This message is intended only for the use of the named addressee. If you are not the intended recipient of this message, unauthorized forwarding, printing, copying, distribution, or using such information is strictly prohibited and may be unlawful. If you have received this in error, you should kindly notify the sender by reply e-mail and immediately destroy this message. Unauthorized interception of this e-mail is a violation of federal criminal law. Applebee's International, Inc. reserves the right to monitor and review the content of all messages sent to and from this e-mail address. Messages sent to or from this e-mail address may be stored on the Applebee's International, Inc. e-mail system. List info : http://www.activedir.org/List.aspx List FAQ : http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
