Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    Never having used the Scripting Host, take this for what it's worth....

    Have you set a reference to the Windows Scripting Host Shell Object?

    Maybe that is the difference?
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBS/VBA/VB and registry editing... (VB6)

    Help a dumb and confused newbie.

    If I use VBScript or even VBA, I can edit the registry by Creating the Windows Scripting Host Shell Object and then using simple commands like RegWrite or RegDelete:

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.RegWrite ...

    However, as best I can tell, this is not an option for VB6. To edit the registry using VB6, I need to:

    1) Declare each editing function from advapi32.dll separately (e.g., Declare Function RegSetValueEx...)
    2) Declare each parameter I might use with a given function (e.g., hkey, ipValueName)
    3) Declare a Type for each parameter (e.g., As Long).
    4) Define Constants for the hives and data values (e.g., Const REG_SZ = 1)
    5) Define Constants for registry permisions (e.g., Const KEY_WRITE = &H20006)

    Then, I can use VB6 to edit the registry. Is this a correct assumption??

    Is there no way to invoke the Windows Scripting Host Shell Object in VB6 like I can in VBS and VBA?

    Also, can I stick ALL the Declarations and Constants I need to edit the registry in single ".bas" module, and then 'refer to' or 'call on' this module each time I want to have a VB6 program edit the registry?

    Please respond as you would to an eight year old. Some people have said I frequently act that old anyway! ;-] THANK YOU.

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    I don't even know how to do that!! (Newbie alert)

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    In VB or VBA, try using

    Set WshShell = CreateObject("WScript.Shell")

    i.e remove the WScript. which precedes CreatObject

    Andrew Cronnolly

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    Since you say it yourself (being a newby), wouldn't it be a bit couragious <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29> to start meddling with the registry?
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  6. #6
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    Not from my viewpoint. I am very adept at using regedit -- and as we all know, Win9x has five default backup copies of the registry stored in the C:WindowsSysbckup.

    There is no harm that I can see... I work in the registry evey day...

  7. #7
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    I'm not sure which library you have to reference, but under Tools|References.. (this is from memory since I don't have access to VB 6 here at work)

    You will be able to select a reference that will allow you access to the Scripting Host.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  8. #8
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    A lot of Corporate Systems Administrators disable/uninstall the Windows Scripting Host on all PCs they administer for "security" reasons.

    I don't know what the reasons are, that's just what I have been told.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  9. #9
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    Andrew -- that does it. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Why wouldn't everyone just do this?? Why would I need to jump through all the hoops of the API coding if I can do it this easy??

    Thank you.

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: VBS/VBA/VB and registry editing... (VB6)

    The reasons are to keep malicious scripts from executing from emails and web downloads.
    Charlotte

  11. #11
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    That does not make sense to me!

    You are saying that programmers go through the hassles of using the API to edit the registry... "to keep malicious scripts from executing from emails and web downloads."

    I am not sure I follow that logic.

    -----------------------------------------------

    If you are instead saying the users disable the WSH for this reason, then MAYBE that makes sense -- until you think about it for about two seconds. Most people disable the WSH by simply disabling the file extension associations to the WSH executable.

    This does NOT render the WSH inoperable, but it does prevent .vbs, js, .wsf, and other files from easily running. Even with every single WSH file extension DIS-associated, the engine still runs this code quite easily.

    Hmmm... you should know this...

  12. #12
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    I can even go so far as to rename (and therefore disable) the WSH executable entirely. And guess what??

    I can STILL run the VBA code and edit the registry.

    So... I do not think "disabling WSH" in any of the usual fashions will stop this. I suspect only completely removing WSH from your system would be sucessful -- but I suspect Windows and especially IE would not like that...
    Attached Images Attached Images

  13. #13
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: VBS/VBA/VB and registry editing... (VB6)

    Renaming it isn't how the administrators block it, and if it *is* blocked, then you won't be able to do it that way.

    You can always use GetSetting and SaveSetting to create and populate or read and individual keys if you don't want to bother with GetPrivateProfileString and WritePrivateProfileString. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

  14. #14
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: VBS/VBA/VB and registry editing... (VB6)

    I'm not doing it because I don't do network administration anymore and haven't in years, but I've worked in offices in the recent past where it definitely *was* disabled. The whole scripting host is disabled and it has nothing to do with what programmers want to do, it is a security issue to protect networks from attack. Trying to get around any network security issue is a good way to get fired in that kind of environment ... especially if you happen to succeed. <img src=/S/cauldron.gif border=0 alt=cauldron width=20 height=20>
    Charlotte

  15. #15
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS/VBA/VB and registry editing... (VB6)

    Interesting. How do administators block it? Please tell me as I would love to test this.

    I do not think GetSettings and SaveSettings are going to do me any good. As best I can tell, they ONLY function in HKLMSoftware key -- and that is pretty limited.

    Additionally, GetPrivateProfileString and WritePrivateProfileString appear to be for .INI files -- not the registry. How are those going to help me editing the registry???

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •