?
Solved

WSH API calls

Posted on 2003-03-20
8
Medium Priority
?
917 Views
Last Modified: 2013-12-03
HI,

Never coded with the WSH before - have code in vb calling the following api functions:

Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal samDesired As Long, phkResult As Long) As Long

the program opens up the key and deletes it - simple!! HOw do I do the same thing using Vbs & WSH ?? It doesn't like declare function - and I get errors when I declare my constants even if I put in the literal values
( ie: Const KEY_ALL_ACCESS = ((&H1F0000 or &H1 or &H2 Or &H4 Or &H8 Or &H10 Or &H20)  and (Not &H100000)) )

Any help would be appreciated,

Thanks,

Tyson


0
Comment
Question by:TysonCakie
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:Koro_das_Master
ID: 8174477
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.RegDelete "HKCU\your_key_here"

--
Complete reference for the WshShell object:

http://msdn.microsoft.com/library/en-us/script56/html/wsObjWshShell.asp
0
 

Author Comment

by:TysonCakie
ID: 8174751
Unfortunitly this call doesn't allow me to delete the certification key I'm after I just get a denied message - theres no option to open the key for 'all_access' as with the vb api calls. Any thoughts on how I can get around this one ??

Thanks



0
 
LVL 1

Expert Comment

by:Koro_das_Master
ID: 8175078
Where is your key? Is it in HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER? If it's HKLM you should check if you have the right permissions.
0
 

Author Comment

by:TysonCakie
ID: 8175144
Its in current user. I have permissions all right - and I can manually delete the key through RegEdit, as well as through VB API calls. But not with the WSH.
Can one use API calls with VBS ? As I'm not sure that the functions exposed by the WSH are adequate.
0
 
LVL 1

Accepted Solution

by:
Koro_das_Master earned 200 total points
ID: 8175700
If your script is running from within Internet Explorer, it will have reduced privileges for "security"

Else, the problem might just be that if you want to delete a key, you must put a final backslash at the end (I just found this one by re-reading the page):

-- (Excerpt from MSDN)--

Remarks

Specify a key-name by ending strName with a final backslash; leave it off to specify a value-name

---
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question