Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:13:02+00:00 2026-06-17T21:13:02+00:00

I’ve been trying to figure out how to properly format these strings for RegWrite

  • 0

I’ve been trying to figure out how to properly format these strings for RegWrite but haven’t been able to figure it out. When finished the script modifies a few areas in the registry so that multiple Excel 2010 workbooks are opened in different windows.

Environment:
Windows 7 Professional x64
Excel 2010

Option Explicit
' =======================================================
' Purpose: This will let you open each Excel Spreadsheet in a seperate window.
' =======================================================

Const HKCR = &H80000000

dim objShell, objReg, strComputer

strComputer = "."

set objShell = WScript.CreateObject("WScript.Shell")
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

' objShell.RegDelete "HKCR\Excel.Sheet.12\shell\Open\ddeexec\"
objReg.DeleteKey HKCR, "Excel.Sheet.12\shell\Open\ddeexec"

objShell.RegWrite "HKCR\Excel.Sheet.12\shell\Open\command\", "C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" "%1", "REG_SZ"
objShell.RegWrite "HKCR\Excel.Sheet.12\shell\Open\command\command", "xb'BV5!!!!!!!!!MKKSkEXCELFiles>VijqBof(Y8'w!FId1gLQ "%1"", "REG_MULTI_SZ"

set objShell = Nothing

Issue 1) For some reason I can’t delete the ddeexec registry key. It does have subkeys and through some reading found out that you can’t delete keys which also have subkeys using objShell.RegDelete so I was trying to use objReg.DeleteKey however neither were successful. I haven’t been able to find anything on a work-around that doesn’t involve deleting every subkey individually.

Issue 2) The text I’m trying to write to HKCR\Excel.Sheet.12\shell\open\command contains a lot of quotes and spaces that I’m having trouble properly escaping. The value in the registry should be "C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" "%1"

Issue 3) The crazy string of characters I’m trying to put in the command key contains a “(” which is resulting in an error “) expected”, I’ve played around with trying to get it formatted correctly like in issue 2. The value in the registry should be xb'BV5!!!!!!!!!MKKSkEXCELFiles>VijqBof(Y8'w!FId1gLQ "%1"

I’ve tried using different things like & chr(34) & and also using """" but haven’t come up with the right combo yet.

Thanks!

Edit: Final solution.

Option Explicit
' ============================================
' Purpose: This will let you open each Excel Spreadsheet in a seperate window.
' =======================================================

Const HKEY_CLASSES_ROOT = &H80000000

Dim strComputer, objReg, strKeyPath

' Create WMI registry object
strComputer = "."
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

' Delete DDE stuff
strKeyPath = "Excel.Sheet.12\shell\Open\ddeexec"
DeleteSubKeys HKEY_CLASSES_ROOT, strKeyPath

' Modify launch commands
strKeyPath = "Excel.Sheet.12\shell\Open\command\"
objReg.SetStringValue HKEY_CLASSES_ROOT, strKeyPath, "", """C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE"" ""%1"""
objReg.SetMultiStringValue HKEY_CLASSES_ROOT, strKeyPath, "command", Array("xb'BV5!!!!!!!!!MKKSkEXCELFiles>VijqBof(Y8'w!FId1gLQ", """%1""")

' =====================================================================
'        Sub: DeleteSubKeys
'       HKEY: The specific root Hive you're editing.
' strKeyPath: Path to specific Key under HKEY.
'    Purpose: Iterate through all subkeys under strKeyPath and delete them.
' http://technet.microsoft.com/en-us/magazine/2006.08.scriptingguy.aspx
' =====================================================================

Sub DeleteSubKeys(HKEY, strKeyPath)

    Dim arrSubkeys, strSubkey

    objReg.EnumKey HKEY, strKeyPath, arrSubkeys

    If IsArray(arrSubkeys) Then
        For Each strSubKey In arrSubkeys
            DeleteSubKeys HKEY, strKeyPath & "\" & strSubkey
        Next
    End If

    objReg.DeleteKey HKEY, strKeyPath
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:13:03+00:00Added an answer on June 17, 2026 at 9:13 pm

    Issue 1:

    You must delete every subkey from the bottom up. Use recursion for that:

    Sub DelKey(hive, key)
      rc = reg.EnumKey(hive, key, subkeys)
      If rc = 0 Then                         ' only proceed if there were no errors
        If Not IsNull(subkeys) Then
          For Each subkey In subkeys
            DelKey hive, key & "\" & subkey  ' <- recurse (descend before delete)
          Next
        End If
        reg.DeleteKey hive, key              ' at this point the key doesn't have
                                             ' subkeys anymore
      End If
    End Sub
    

    Issue 2:

    Double quotes within a string must be escaped by doubling them:

    objShell.RegWrite "HKCR\Excel.Sheet.12\shell\Open\command\" _
      , """C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE"" ""%1""" _
      , "REG_SZ"
    

    Issue 3:

    As documented RegWrite does not support the type REG_MULTI_SZ. You need to use SetMultiStringValue for this. You need to escape inner double quotes here too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.