?
Solved

WSH API calls

Posted on 2003-03-20
8
Medium Priority
?
905 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

770 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