Hi All, How can I set the value in Registry.Is it possible through Lotus Script.
Any Body give me the sample code.
Please Guide me.
Pawan
Hi All, How can I set the value in Registry.Is it possible through Lotus Script.
Any Body give me the sample code.
Please Guide me.
Pawan
Subject: How To Set A Value in Registry
Yes it’s possible. Search this forum and the 4/5 forum for “advapi32.dll” - there are several examples of how this works. If you’ve done it using VBA, it should be pretty easy for you. If you have not done this before - hang on, it’s a bit complex. I’d recommend you spend some quality time with other Windows API resources if you need more info.
I’m not sure, but you may want to check the Sandbox also.
HTH
Doug
Subject: How To Set A Value in Registry
Here is a class I’ve made and used a lot just for reading/writing/deleting values in the registry:
’ — CODE START —
Option Public
Option Explicit
'Security Mask constants
Public Const READ_CONTROL = &H20000
Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const STANDARD_RIGHTS_READ = READ_CONTROL
Public Const STANDARD_RIGHTS_WRITE = READ_CONTROL
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Public Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE))
Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
’ Registry value type definitions / Possible registry data types
Public Const REG_NONE = 0
Public Const REG_SZ = 1
Public Const REG_EXPAND_SZ = 2
Public Const REG_BINARY = 3
Public Const REG_DWORD = 4
Public Const REG_LINK = 6
Public Const REG_MULTI_SZ = 7
Public Const REG_RESOURCE_LIST = 8
’ Registry section definitions
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_DYN_DATA = &H80000006
’ Codes returned by Reg API calls
Public Const ERROR_NONE = 0 ’ Compare this to Public Const ERROR_SUCCESS = 0&
Public Const ERROR_BADDB = 1
Public Const ERROR_BADKEY = 2
Public Const ERROR_CANTOPEN = 3
Public Const ERROR_CANTREAD = 4
Public Const ERROR_CANTWRITE = 5
Public Const ERROR_OUTOFMEMORY = 6
Public Const ERROR_INVALID_PARAMETER = 7
Public Const ERROR_ACCESS_DENIED = 8
Public Const ERROR_INVALID_PARAMETERS = 87
Public Const ERROR_NO_MORE_ITEMS = 259
’ Registry API functions used in this module (there are more of them)
Declare Function RegQueryValueEx Lib “advapi32.dll” Alias “RegQueryValueExA” (Byval Hkey As Long, Byval lpValueName As String, Byval lpReserved As Long, lpType As Long, Byval lpData As String, lpcbData As Long) As Long
Declare Function RegQueryValueExAny Lib “advapi32.dll” Alias “RegQueryValueExA” (Byval Hkey As Long, Byval lpValueName As String, Byval lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Declare Function RegSetValueExAny Lib “advapi32.dll” Alias “RegSetValueExA” (Byval Hkey As Long, Byval lpValueName As String, Byval Reserved As Long, Byval dwType As Long, lpData As Any, Byval cbData As Long) As Long
Declare Function RegSetValueExString Lib “advapi32.dll” Alias “RegSetValueExA” (Byval Hkey As Long, Byval lpValueName As String, Byval Reserved As Long, Byval dwType As Long, Byval lpValue As String, Byval cbData As Long) As Long
Declare Function RegSetValueExLong Lib “advapi32.dll” Alias “RegSetValueExA” (Byval Hkey As Long, Byval lpValueName As String, Byval Reserved As Long, Byval dwType As Long, lpValue As Long, Byval cbData As Long) As Long
Declare Function RegDeleteValue Lib “advapi32.dll” Alias “RegDeleteValueA” (Byval Hkey As Long, Byval lpValueName As String) As Long
Declare Function RegEnumValue Lib “advapi32.dll” Alias “RegEnumValueA” (Byval Hkey As Long, Byval dwIndex As Long, Byval lpValueName As String, lpcbValueName As Long, Byval lpReserved As Long, lpType As Long, Byval lpData As String, lpcbData As Long) As Long
Declare Function RegOpenKey Lib “advapi32.dll” Alias “RegOpenKeyA” (Byval Hkey As Long, Byval lpSubKey As String, phkResult As Long) As Long
Declare Function RegOpenKeyEx Lib “advapi32.dll” Alias “RegOpenKeyExA” (Byval Hkey As Long, Byval lpSubKey As String, Byval ulOptions As Long, Byval samDesired As Long, phkResult As Long) As Long
Declare Function RegCloseKey Lib “advapi32.dll” (Byval Hkey As Long) As Long
Declare Function RegCreateKey Lib “advapi32.dll” Alias “RegCreateKeyA” (Byval Hkey As Long, Byval lpSubKey As String, phkResult As Long) As Long
Declare Function RegFlushKey Lib “advapi32.dll” (Byval Hkey As Long) As Long
Declare Function RegEnumKey Lib “advapi32.dll” Alias “RegEnumKeyA” (Byval Hkey As Long, Byval dwIndex As Long, Byval lpName As String, Byval cbName As Long) As Long
Declare Function RegDeleteKey Lib “advapi32.dll” Alias “RegDeleteKeyA” (Byval Hkey As Long, Byval lpSubKey As String) As Long
Private m_LastError As Long ’ Local storage of last error code returned from the API-commands
Private m_ValueType As Long ’ Local storage of last valuetype returned from registry
Private m_KeyName As String ’ Local storage of last name of key returned from registry
Private m_KeyValue As String 'Local storage of last value of key returned from registry
Private m_KeyType As Long ’ Local storage of last keytype returned from registry
Private m_KeyIndex As Long ’ Local storage of last index retreived from registry. Zero-based index.
’ User-defined error codes/messages:
Private Const ERROR_UNSUPPORTEDTYPE = 1001
Private Const ERROR_ARGUMENT = 1002
Private Const m_ErrUnsupported = “The registry valuetype is not supported in this Class.”
Private Const m_ErrArgument = “Incorrect value passed in argument.”
’ Class-definition “Registry”:
Public Class Registry
Public Property Get LastError() As Long
' Retreives the last error returned from API-commands
' There is NO "Property Set" since this is a write protected property. Only the class itself can change the value.
LastError = m_LastError
End Property
Public Property Get KeyName() As String
' Last name of key returned from registry
' There is NO "Property Set" since this is a write protected property. Only the class itself can change the value.
KeyName = m_KeyName
End Property
Public Property Get KeyValue() As String
' Last value of key returned from registry
' There is NO "Property Set" since this is a write protected property. Only the class itself can change the value.
KeyValue = m_KeyValue
End Property
Public Property Get KeyType() As Long
' Last keytype returned from the registry
' There is NO "Property Set" since this is a write protected property. Only the class itself can change the value.
KeyType = m_KeyType
End Property
Public Property Get KeyIndex() As Long
' Last index used when retreiving values/keys from registry
KeyIndex = m_KeyIndex
End Property
Public Property Set KeyIndex() As Long
' Index to use when retreiving values/keys from registry.
' If this value = zero then get the first value/key
m_KeyIndex = KeyIndex
End Property
Public Sub New()
m_LastError = ERROR_NONE
End Sub
Public Sub Terminate()
m_LastError = ERROR_NONE
m_KeyValue = ""
m_KeyName = ""
m_KeyType = 0
End Sub
Public Function ReadRegValue(Byval Group As Long, Byval Section As String, Byval Key As String) As String
' This routine allows you to get values from anywhere in the Registry, it currently
' only handles string, double word and binary values. Binary values are returned as
' hex strings.
' Example:
' Msgbox ReadRegValue(HKEY_USERS, ".DEFAULT\Test", "No1")
Dim lResult As Long
Dim lKeyValue As Long
Dim lDataTypeValue As Long
Dim lValueLength As Long
Dim sValue As String
Dim sTemp1 As String
Dim sTemp2 As String
Dim counter As Integer
'On Error Resume Next
lResult = RegOpenKey(Group, Section, lKeyValue)
sValue = Space$(2048)
lValueLength = Len(sValue)
lResult = RegQueryValueEx(lKeyValue, Key, 0&, lDataTypeValue, sValue, lValueLength)
If lResult = ERROR_NONE Then
Select Case lDataTypeValue
'Return a string field as a string
Case REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ
sValue = Left$(sValue, lValueLength - 1)
'Return a binary field as a hex string (2 chars per byte)
Case REG_BINARY
sTemp2 = ""
For counter = 1 To lValueLength
sTemp1 = Hex(Asc(Mid(sValue, counter, 1)))
If Len(sTemp1) = 1 Then sTemp1 = "0" & sTemp1
If counter < lValueLength Then
sTemp2 = sTemp2 + sTemp1 + ","
Else
sTemp2 = sTemp2 + sTemp1
End If
Next
sValue = sTemp2
'Return a DWord field as a decimal string
Case REG_DWORD
sValue = Format$(Asc(Mid$(sValue, 1, 1)) + &H100& * Asc(Mid$(sValue, 2, 1)) + &H10000 * Asc(Mid$(sValue, 3, 1)) + &H1000000 * Cdbl(Asc(Mid$(sValue, 4, 1))), "000")
' Take a string and turn it into hexform for the registry. 0x0000001(1)
sTemp1 = Hex(sValue)
sTemp2 = "0x"
For counter = 1 To (8 - Len(sValue))
sTemp2 = sTemp2 + "0"
Next
For counter = 1 To (Len(sValue) - Len(sTemp1))
sTemp2 = sTemp2 + "0"
Next
sValue = sTemp2 + sTemp1 + "(" + sValue + ")"
'Not yet implemented
Case REG_NONE, REG_LINK, REG_RESOURCE_LIST
Error ERROR_UNSUPPORTEDTYPE, m_ErrUnsupported
'If value not in span
Case Else
Error ERROR_ARGUMENT, m_ErrArgument
End Select
Else
sValue = "Not Found"
End If
lResult = RegCloseKey(lKeyValue)
m_LastError = lResult
If sValue = "Not Found" Then
sValue = ""
m_LastError = ERROR_NO_MORE_ITEMS
m_KeyValue = ""
m_KeyName = ""
m_KeyType = 0
End If
ReadRegValue = sValue
End Function
Public Sub ReadRegValueAll(Byval Group As Long, Byval Section As String, Byval Idx As Long)
' This routine allows you to get all the values from anywhere in the Registry under any
' given subkey, it currently only returns string, binary and DWord values.
' Example - returns list of names/values to multiline text box
' Dim Res As Variant
' Dim i As Long
' Res = ReadRegValueAll(HKEY_USERS, ".DEFAULT\Test", i)
' Do Until Res(2) = "Not Found"
' msgbox Res(1) + " - " + Res(2)
' i = i + 1
' Res = ReadRegValueAll(HKEY_USERS, ".DEFAULT\Test", i)
' Loop
Dim lResult As Long
Dim lKeyValue As Long
Dim lDataTypeValue As Long
Dim lValueLength As Long
Dim lValueNameLength As Long
Dim sValueName As String
Dim sValue As String
Dim sTemp1 As String
Dim sTemp2 As String
Dim counter As Integer
If Idx = 0 Then
Idx = m_KeyIndex
End If
lResult = RegOpenKey(Group, Section, lKeyValue)
sValue = Space$(2048)
sValueName = Space$(2048)
lValueLength = Len(sValue)
lValueNameLength = Len(sValueName)
lResult = RegEnumValue(lKeyValue, Idx, sValueName, lValueNameLength, 0&, lDataTypeValue, sValue, lValueLength)
If lResult = ERROR_NONE Then
Select Case lDataTypeValue
'Return a string field as a string
Case REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ
sValue = Left$(sValue, lValueLength - 1)
'Return a binary field as a hex string (2 chars per byte)
Case REG_BINARY
sTemp2 = ""
For counter = 1 To lValueLength
sTemp1 = Hex(Asc(Mid(sValue, counter, 1)))
If Len(sTemp1) = 1 Then sTemp1 = "0" & sTemp1
If counter < lValueLength Then
sTemp2 = sTemp2 + sTemp1 + ","
Else
sTemp2 = sTemp2 + sTemp1
End If
Next
sValue = sTemp2
'Return a DWord field as a decimal string
Case REG_DWORD
sValue = Format$(Asc(Mid$(sValue, 1, 1)) + &H100& * Asc(Mid$(sValue, 2, 1)) + &H10000 * Asc(Mid$(sValue, 3, 1)) + &H1000000 * Cdbl(Asc(Mid$(sValue, 4, 1))), "000")
' Take a string and turn it into hexform for registryt. 0x0000001(1)
sTemp1 = Hex(sValue)
sTemp2 = "0x"
For counter = 1 To (8 - Len(sValue))
sTemp2 = sTemp2 + "0"
Next
For counter = 1 To (Len(sValue) - Len(sTemp1))
sTemp2 = sTemp2 + "0"
Next
sValue = sTemp2 + sTemp1 + "(" + sValue + ")"
'Not yet implemented
Case REG_NONE, REG_LINK, REG_RESOURCE_LIST
Error ERROR_UNSUPPORTEDTYPE, m_ErrUnsupported
'If value not in span
Case Else
Error ERROR_ARGUMENT, m_ErrArgument
End Select
sValueName = Left$(sValueName, lValueNameLength)
Else
sValue = "Not Found"
End If
lResult = RegCloseKey(lKeyValue)
m_LastError = lResult
m_KeyName = sValueName
m_KeyValue = sValue
m_KeyType = lDataTypeValue
m_KeyIndex = Idx
If sValue = "Not Found" Then
m_LastError = ERROR_NO_MORE_ITEMS
m_KeyValue = ""
m_KeyName = ""
m_KeyType = 0
End If
End Sub
Public Sub WriteRegValue(Byval Group As Long, Byval Section As String, Byval Key As String, Byval ValType As Long, Byval Value As Variant)
' This routine allows you to write values into the entire Registry, it currently
' only handles string and double word values.
' Example
' WriteRegValue HKEY_USERS, ".DEFAULT\Test", "No1", REG_SZ, "NewValueHere"
' WriteRegValue HKEY_USERS, ".DEFAULT\Test", "No2", REG_BINARY, "4b6e7574"
' WriteRegValue HKEY_USERS, ".DEFAULT\Test", "No3", REG_DWORD, "31"
Dim lResult As Long
Dim lKeyValue As Long
Dim InLen As Long
Dim lNewVal As Long
Dim sNewVal As String
lResult = RegCreateKey(Group, Section, lKeyValue)
Select Case ValType
'Save a string value
Case REG_SZ
Value = Value + Chr(0) ' Fixes empty string bug
sNewVal = Cstr(Value)
InLen = Len(sNewVal)
lResult = RegSetValueExString(lKeyValue, Key, 0&, ValType, sNewVal, InLen)
m_LastError = lResult
'Save a binary value
Case REG_BINARY
sNewVal = Value
InLen = Len(sNewVal)
lResult = RegSetValueExString(lKeyValue, Key, 0&, ValType, sNewVal, InLen)
m_LastError = lResult
'Save a DWord value
Case REG_DWORD
lNewVal = Clng(Value)
InLen = 4
lResult = RegSetValueExLong(lKeyValue, Key, 0&, ValType, lNewVal, InLen)
m_LastError = lResult
'Not yet implemented
Case REG_NONE, REG_EXPAND_SZ, REG_LINK, REG_MULTI_SZ, REG_RESOURCE_LIST
Error ERROR_UNSUPPORTEDTYPE, m_ErrUnsupported
'If value not in span
Case Else
Error ERROR_ARGUMENT, m_ErrArgument
End Select
lResult = RegFlushKey(lKeyValue)
lResult = RegCloseKey(lKeyValue)
End Sub
Public Sub DeleteRegValue(Byval Group As Long, Byval Section As String, Byval Key As String)
' This routine deletes a specified value from below a specified subkey.
' Be very careful using this function.
' Example
' DeleteRegValue HKEY_USERS, ".DEFAULT\Test", "No1"
Dim lResult As Long
Dim lKeyValue As Long
lResult = RegOpenKey(Group, Section, lKeyValue)
lResult = RegDeleteValue(lKeyValue, Key)
m_LastError = lResult
lResult = RegCloseKey(lKeyValue)
End Sub
Public Sub ReadSubkeyAll(Byval Group As Long, Byval Section As String, Byval Idx As Long)
' This routine enumerates the subkeys under any given key
' Call repeatedly until "Not Found" is returned - store values in array or something
' Example - this example just adds all the subkeys to a string - you will probably want to
' save then into an array or something.
' Dim Res As String
' Dim i As Long
' Res = ReadSubkeyAll(HKEY_USERS, ".DEFAULT", i)
' Do Until Res = "Not Found"
' Msgbox Res + vbCrLf
' i = i + 1
' Res = ReadSubkeyAll(HKEY_USERS, ".DEFAULT", i)
' Loop
Dim lResult As Long, lKeyValue As Long, lDataTypeValue As Long, lValueLength As Long, sValue As String, td As Double
If Idx = 0 Then
Idx = m_KeyIndex
End If
lResult = RegOpenKey(Group, Section, lKeyValue)
sValue = Space$(2048)
lValueLength = Len(sValue)
lResult = RegEnumKey(lKeyValue, Idx, sValue, lValueLength)
m_LastError = lResult
If lResult = ERROR_NONE Then
m_KeyName = Left$(sValue, Instr(sValue, Chr(0)) - 1)
m_KeyValue = m_KeyName
m_KeyType = 0
Else
sValue = ""
m_LastError = ERROR_NO_MORE_ITEMS
m_KeyValue = ""
m_KeyName = ""
m_KeyType = 0
End If
lResult = RegCloseKey(lKeyValue)
End Sub
Public Sub WriteSubkey(Group As Long, Section As String)
' This routine writes a specified key.
' Example
' WriteSubkey HKEY_USERS, ".DEFAULT\Test"
Dim lResult As Long
Dim keyhand&
lResult = RegCreateKey(Group, Section, keyhand&)
m_LastError = lResult
lResult = RegCloseKey(keyhand&)
End Sub
Public Sub DeleteSubkey(Byval Group As Long, Byval Section As String)
' This routine deletes a specified key (and all its subkeys and values if on Win95) from the registry.
' Be very careful using this function.
' Example
' DeleteSubkey HKEY_USERS, ".DEFAULT\Test"
' DeleteSubkey should return zero (0) on success. All other values indicates errors...
Dim lResult As Long
lResult = RegDeleteKey(Group, Section)
m_LastError = lResult
End Sub
End Class
Sub Initialize
End Sub
Sub Terminate
End Sub
’ — CODE END —
This example will retreive the path where the Notes client is installed and present it in a messagebox:
Dim regObj As New Registry
Msgbox regObj.ReadRegValue(HKEY_LOCAL_MACHINE, “Software\Lotus Notes\6.0”, “Path”)
Set regObj = Nothing
This example will read all values in all keys under the specified section. The result will be presented in a messagebox (one for each key found):
Dim regObj As New Registry
Dim iCount As Integer
Do Until regObj.LastError <> 0
Call regObj.ReadRegValueAll(HKEY_LOCAL_MACHINE, "Software\Lotus Notes\6.0", iCount)
If regObj.LastError = 0 Then
Msgbox regObj.KeyValue, 64, "Registry Object- Value of key: " & regObj.KeyName
End If
iCount = iCount + 1
Loop
Set regObj = Nothing
Subject: Easier Way
You can use an COM Object from the windows scripting host, the WSH should be included on all Win XP and Win 2000 systems. On NT, you have to install it.
Set wsh = createobject("Wscript.Shell")
Call wsh.RegWrite(REGKEY,Value)
A little bit shorter, than the Win32 API function, but WSH must be installed.
Andreas Hoster
Subject: Easier Way-AWESOME! Just added to FAQ of FAQs
How cool is that little trick?I’m going to look for information on WSH, but in the mean time, do you have a list of other neat little registry hacks?
I’m off to link this thread to the FAQ of FAQs.
Thank you for posting this code.
Doug
Subject: More WSH Tricks - setting the default printer
I’ve seen a bunch of API calls that try to set the default printer - most fail or work inconsistently. I just tried the code below and it works like a charm. (WSH does not work on all versions of Windows - your mileage may vary).
The default printer is instantly correct.
Sub Initialize
Dim net
Set net = CreateObject("WScript.Network")
net.SetDefaultPrinter "PrinterNameOrUNCGoesHere"
End Sub
Link to all of the properties and methods available are here:
Subject: My experience using this code toset the default printer
When I use this code from Notes 6.5 client it DOES change the windows default printer. Open the windows print manager and the little check mark is indeed by the programmatically changed windows default printer.
Here comes the BUT:
In W2k: If the user has NOT previously printed another doc (ie like, for instance, an email) then Notes nicely prints to the NEW default printer. If the user HAS previously printed another doc, then NOTES disregards the New Windows default printer just programmatically set and prints to the printer the user just printed to.
In WXP: The Windows Print manager shows the check mark by the NEW default printer (so the code DOES change the windows default printer) but Lotus Notes NEVER tries to print to it unless the user pre-selects it in a print function.
My half baked solution:
'set default printer using code posted here altho I’m not sure 'its really necessary. Then do the following:
Messagebox(“Dear user, please choose the correct printer driver when the print dialog pops up or this wont work”)
Set coll2 = db.Unprocesseddocuments
For x = 1 To coll2.count
If x=1 Then
'First doc printed–display printer dialog
Call uidoc.Print
Else
'after 1st document–dont display printer dialog
'without a new user choice, notes prints to one the user
'just printed to, totally disregarding the Windows default 'printer
Call uidoc.Print( 1 )
Next
End If
Subject: Changing Default Printer
No matter which method I tried to get the printer to change in the backend, it didn’t reflect in Notes. Only the Windows default printer is set correctly.
The only solution was to change it in the UI:
Set wsh = CreateObject(“WScript.Shell”)
’ launch the print window, change to “CutePDF Writer”, then hit Enter
wsh.SendKeys(“%FP”) ’ Alt, File, Print
wsh.SendKeys(“Cute”) ’ The first few chars of “CutePDF Writer”
wsh.SendKeys(“{ENTER}”)
That does the trick!
The only drawback is the flash on the screen.
Subject: Changing Default Printer–works sometimes
My network people have defined printers and printer names for everyone.
So…everyone has the following printers:
CutePDF <<the printer I want to select.
CutePDFColor<<This is the one your prescribed keystrokes select for me
and when I do a sendkeys of “Cute” it gets the WRONG one!
I tried adding a space after Cute but that didnt work either.
Sending a key down keystroke might solve the problem but I could still be bitten if everyone’s workstation isnt set up exactly the same. Just wondering why it picks CutePDFColor. My guess is that it was set up first.
If I use a very distinct printer name, however, this does work. So now I get to talk my admin people into changing the printer name to something very unique.
So. Thanx for the suggestion.
PS do you know how to make Lotus Notes Client pay attention to a windows printer change broadcast? Or did you come up with the keystroke solution because Notes Client will NOT listen to a windows printer change broadcast?
Subject: RE: Changing Default Printer–works sometimes
Sorry the solution didn’t work for you. In my environment there is only 1 “CutePDF”, so I didn’t have to worry about your problem.
I came up with this idea solely because I could never get notes to realize the change in the windows default printer.
I checked registry entries and everything, no luck.
Subject: RE: Changing Default Printer–works sometimes
Thanx for your response. Your keystroke thing is the best solution yet and will give my printer a unique name so I can use your approach. Thanx for confirming that I’m not the ONLY one who cant make Notes listen to windows broadcast messages. Take care.
Subject: RE: Changing Default Printer
Please disregard.
Subject: RE: Easier Way-AWESOME! Just added to FAQ of FAQs
Sorry for replying so late, but I was the last week not at the office.
You can do quite a lot with the WSH, for example, using the WSH together with the Windows Management Instrumentation, I have written a script which monitors all Plug & Play devices and logs all connected USB devices.
Some samples:
For writing and reading the registry:
Set wsh = createobject(“Wscript.Shell”)
Call wsh.RegWrite(REGKEY,Value) ’ Writing
Call wsh.RegDelete(REGKEY) ’ Deleting a key
x = wsh.RegRead(REGKEY) ’ Reading a key
Logging to the Event-Log:
Set wsh = createobject(“Wscript.Shell”)
call wsh.LogEvent(Type, Message)
Type Value
0 SUCCESS
1 ERROR
2 WARNING
4 INFORMATION
8 AUDIT_SUCCESS
16 AUDIT_FAILURE
Message: The text appearing in the System-EventLog
Andreas Hoster