Office 2013 non C2R & Excel work around.

Utilities designed for use with Sandboxie
Sklipnott
Posts: 6
Joined: Sat Apr 23, 2016 11:33 am

Office 2013 non C2R & Excel work around.

Post by Sklipnott » Sat Apr 23, 2016 11:54 am

Windows 8.1 x64
Sandboxie 5.11.5 (registered)
Excel (2013 and/or 2016, it makes no difference which one)
Excel > Forced program

When double click an .xls/.xlsx file Excel runs forced within Sandboxie attempting to open the file, with the following error:

Image

Craig@Invincea
Sandboxie Support
Sandboxie Support
Posts: 3523
Joined: Thu Jun 18, 2015 3:00 pm
Location: DC Metro Area

Re: There was a problem sending the command to the program.

Post by Craig@Invincea » Sun Apr 24, 2016 8:23 am

Did you restart the Office C2R service as outlined here? http://forums.sandboxie.com/phpBB3/view ... 11&t=22645

Have you tried OPENING EXCEL first, then the EXCEL document?

Sklipnott
Posts: 6
Joined: Sat Apr 23, 2016 11:33 am

Re: There was a problem sending the command to the program.

Post by Sklipnott » Sun Apr 24, 2016 12:51 pm

Craig@Invincea wrote:Did you restart the Office C2R service as outlined here? http://forums.sandboxie.com/phpBB3/view ... 11&t=22645
Not using C2R here.
Craig@Invincea wrote: Have you tried OPENING EXCEL first, then the EXCEL document?
It actually works yet I purchased Sandboxie for its "Forced Programs" feature. I need this feature to work on Excel.

Craig@Invincea
Sandboxie Support
Sandboxie Support
Posts: 3523
Joined: Thu Jun 18, 2015 3:00 pm
Location: DC Metro Area

Re: There was a problem sending the command to the program.

Post by Craig@Invincea » Sun Apr 24, 2016 3:28 pm

Um, any version after 2013 is Click2Run.

there is very very good chance the 2013 version you are using is as well.

You can determine that by following the instructions here http://windowsitpro.com/microsoft-offic ... run-or-not

Otherwise, if you don't restart the C2R service injecting the SBIE code, it will not work for you.

And there is a long standing "best use" case you should launch Excel first, then open your file. This has been the case long before C2R and is a recommended work around. Just click Excel to have it force open. Then load your file. You can then leave Office/Excel running in the SB and when you click on any DOCx or Excel file, it will force open correctly.

Sklipnott
Posts: 6
Joined: Sat Apr 23, 2016 11:33 am

Re: There was a problem sending the command to the program.

Post by Sklipnott » Sun Apr 24, 2016 5:57 pm

Craig@Invincea wrote:Um, any version after 2013 is Click2Run
This is a legacy MSI installation.
Craig@Invincea wrote: And there is a long standing "best use" case you should launch Excel first, then open your file. This has been the case long before C2R and is a recommended work around. Just click Excel to have it force open. Then load your file.
This actually works as expected. Not convenient for me though.
Craig@Invincea wrote: You can then leave Office/Excel running in the SB and when you click on any DOCx or Excel file, it will force open correctly.
It doesn't work whatsoever. The already first running Excel instance is running fine, then when double click any .xls/.xlsx file, same error "There was a problem sending the command to the program" pops up.

Syrinx
Sandboxie Guru
Sandboxie Guru
Posts: 621
Joined: Fri Nov 13, 2015 4:11 pm

Re: There was a problem sending the command to the program.

Post by Syrinx » Sun Apr 24, 2016 7:43 pm

Note:You may want to open regedit and export the HKEY_CLASSES_ROOT\Excel.Sheet.8\ and HKEY_CLASSES_ROOT\Excel.Sheet.12\ keys prior to testing this in case you need to revert them!
*Highly recommended*

Please give one of these a try depending on your version eg 2013/2016 and 32 or 64 build assuming they were installed to the default locations...Have only tested the 2013 32 bit one in a VM so I'm unsure of the others! ~ The x64 entries ones are a bit more likely to fail and if so if someone could share the exported key I can likely correct it. :-/

Changes are essentially removing the ddeexec key and changing the /dde at the end of all of them to "%1" to prevent usage of the dynamic data exchange parts which seem to cause the error and just pass the file path instead.

Just save the appropriate one to a text file, rename to .reg and then add to the registry.

Excel 2013 (x86)
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\ddeexec]

[HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\command]
@="\"C:\\Program Files (x86)\\Microsoft Office\\Office15\\EXCEL.EXE\" \"%1\""
"command"=hex(7):7a,00,71,00,50,00,5e,00,56,00,35,00,21,00,21,00,21,00,21,00,\
21,00,21,00,21,00,21,00,21,00,4d,00,4b,00,4b,00,53,00,6b,00,45,00,58,00,43,\
00,45,00,4c,00,46,00,69,00,6c,00,65,00,73,00,3e,00,6c,00,56,00,57,00,41,00,\
28,00,54,00,56,00,6b,00,4d,00,41,00,49,00,53,00,35,00,44,00,68,00,5d,00,33,\
00,6e,00,56,00,4f,00,20,00,22,00,25,00,31,00,22,00,00,00,00,00

[-HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\ddeexec]

[HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\command]
@="\"C:\\Program Files (x86)\\Microsoft Office\\Office15\\EXCEL.EXE\" \"%1\""
"command"=hex(7):7a,00,71,00,50,00,5e,00,56,00,35,00,21,00,21,00,21,00,21,00,\
21,00,21,00,21,00,21,00,21,00,4d,00,4b,00,4b,00,53,00,6b,00,45,00,58,00,43,\
00,45,00,4c,00,46,00,69,00,6c,00,65,00,73,00,3e,00,6c,00,56,00,57,00,41,00,\
28,00,54,00,56,00,6b,00,4d,00,41,00,49,00,53,00,35,00,44,00,68,00,5d,00,33,\
00,6e,00,56,00,4f,00,20,00,22,00,25,00,31,00,22,00,00,00,00,00
Excel 2013 (x64)
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\ddeexec]

[HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\command]
@="\"C:\\Program Files\\Microsoft Office\\Office15\\EXCEL.EXE\" \"%1\""
"command"=hex(7):7a,00,71,00,50,00,5e,00,56,00,35,00,21,00,21,00,21,00,21,00,\
21,00,21,00,21,00,21,00,21,00,4d,00,4b,00,4b,00,53,00,6b,00,45,00,58,00,43,\
00,45,00,4c,00,46,00,69,00,6c,00,65,00,73,00,3e,00,6c,00,56,00,57,00,41,00,\
28,00,54,00,56,00,6b,00,4d,00,41,00,49,00,53,00,35,00,44,00,68,00,5d,00,33,\
00,6e,00,56,00,4f,00,20,00,22,00,25,00,31,00,22,00,00,00,00,00

[-HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\ddeexec]

[HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\command]
@="\"C:\\Program Files\\Microsoft Office\\Office15\\EXCEL.EXE\" \"%1\""
"command"=hex(7):7a,00,71,00,50,00,5e,00,56,00,35,00,21,00,21,00,21,00,21,00,\
21,00,21,00,21,00,21,00,21,00,4d,00,4b,00,4b,00,53,00,6b,00,45,00,58,00,43,\
00,45,00,4c,00,46,00,69,00,6c,00,65,00,73,00,3e,00,6c,00,56,00,57,00,41,00,\
28,00,54,00,56,00,6b,00,4d,00,41,00,49,00,53,00,35,00,44,00,68,00,5d,00,33,\
00,6e,00,56,00,4f,00,20,00,22,00,25,00,31,00,22,00,00,00,00,00
Excel 2016 (x86)
Windows Registry Editor Version 5.00


[-HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\ddeexec]

[HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\command]
@="\"C:\\Program Files (x86)\\Microsoft Office\\Office16\\EXCEL.EXE\" \"%1\""
"command"=hex(7):7a,00,6e,00,3d,00,42,00,56,00,35,00,21,00,21,00,21,00,21,00,\
21,00,21,00,21,00,21,00,21,00,4d,00,4b,00,4b,00,53,00,6b,00,45,00,58,00,43,\
00,45,00,4c,00,46,00,69,00,6c,00,65,00,73,00,3e,00,3f,00,25,00,38,00,47,00,\
69,00,63,00,4b,00,63,00,76,00,39,00,6f,00,49,00,60,00,6b,00,77,00,24,00,3d,\
00,5b,00,55,00,5b,00,20,00,22,00,25,00,31,00,22,00,00,00,00,00

[-HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\ddeexec]

[HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\command]
@="\"C:\\Program Files (x86)\\Microsoft Office\\Office16\\EXCEL.EXE\" \"%1\""
"command"=hex(7):7a,00,6e,00,3d,00,42,00,56,00,35,00,21,00,21,00,21,00,21,00,\
21,00,21,00,21,00,21,00,21,00,4d,00,4b,00,4b,00,53,00,6b,00,45,00,58,00,43,\
00,45,00,4c,00,46,00,69,00,6c,00,65,00,73,00,3e,00,3f,00,25,00,38,00,47,00,\
69,00,63,00,4b,00,63,00,76,00,39,00,6f,00,49,00,60,00,6b,00,77,00,24,00,3d,\
00,5b,00,55,00,5b,00,20,00,22,00,25,00,31,00,22,00,00,00,00,00
Excel 2016 (x64)
Windows Registry Editor Version 5.00


[-HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\ddeexec]

[HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\command]
@="\"C:\\Program Files\\Microsoft Office\\Office16\\EXCEL.EXE\" \"%1\""
"command"=hex(7):7a,00,6e,00,3d,00,42,00,56,00,35,00,21,00,21,00,21,00,21,00,\
21,00,21,00,21,00,21,00,21,00,4d,00,4b,00,4b,00,53,00,6b,00,45,00,58,00,43,\
00,45,00,4c,00,46,00,69,00,6c,00,65,00,73,00,3e,00,3f,00,25,00,38,00,47,00,\
69,00,63,00,4b,00,63,00,76,00,39,00,6f,00,49,00,60,00,6b,00,77,00,24,00,3d,\
00,5b,00,55,00,5b,00,20,00,22,00,25,00,31,00,22,00,00,00,00,00

[-HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\ddeexec]

[HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\command]
@="\"C:\\Program Files\\Microsoft Office\\Office16\\EXCEL.EXE\" \"%1\""
"command"=hex(7):7a,00,6e,00,3d,00,42,00,56,00,35,00,21,00,21,00,21,00,21,00,\
21,00,21,00,21,00,21,00,21,00,4d,00,4b,00,4b,00,53,00,6b,00,45,00,58,00,43,\
00,45,00,4c,00,46,00,69,00,6c,00,65,00,73,00,3e,00,3f,00,25,00,38,00,47,00,\
69,00,63,00,4b,00,63,00,76,00,39,00,6f,00,49,00,60,00,6b,00,77,00,24,00,3d,\
00,5b,00,55,00,5b,00,20,00,22,00,25,00,31,00,22,00,00,00,00,00
Last edited by Syrinx on Sun Apr 24, 2016 8:27 pm, edited 1 time in total.
http://goo.gl/p8qFCf
https://www.youtube.com/watch?v=vIxWgVOCexU

Mr.X
Posts: 595
Joined: Sat Jul 13, 2013 9:34 am
Location: Mexico

Re: There was a problem sending the command to the program.

Post by Mr.X » Sun Apr 24, 2016 8:22 pm

@syrinx

Thanks bro! Thank you so much! It works!

Long time I've been looking for a solution to this problem as well, a long time.

You're very kind. 8)
Windows 8.1 x64 EN | Sandboxie latest beta or stable | All software latest versions unless stated otherwise

Sklipnott
Posts: 6
Joined: Sat Apr 23, 2016 11:33 am

Re: Office 2013 non C2R & Excel work around.

Post by Sklipnott » Mon Apr 25, 2016 11:07 am

I can confirm those registry tweaks worked indeed.

Thanks a lot Mr. syrinx for your kind reply.

Also thanks to Invincea for keep maintaining Sandboxie too.

Craig@Invincea
Sandboxie Support
Sandboxie Support
Posts: 3523
Joined: Thu Jun 18, 2015 3:00 pm
Location: DC Metro Area

Re: Office 2013 non C2R & Excel work around.

Post by Craig@Invincea » Mon Apr 25, 2016 8:56 pm

I moved this topic to contributed utilities. Great info from syrinx and it can come in handy in the future so it doesn't get lost in the noise of the general forum posts.

Sklipnott
Posts: 6
Joined: Sat Apr 23, 2016 11:33 am

Re: Office 2013 non C2R & Excel work around.

Post by Sklipnott » Fri Apr 29, 2016 10:23 am

I spoke too early the other day indeed:
Sklipnott wrote:I can confirm those registry tweaks worked indeed.
Those scripts won't work on different machines. Unfortunately I don't have scripting skills to fix them. Please provide a solution.

Craig@Invincea
Sandboxie Support
Sandboxie Support
Posts: 3523
Joined: Thu Jun 18, 2015 3:00 pm
Location: DC Metro Area

Re: Office 2013 non C2R & Excel work around.

Post by Craig@Invincea » Fri Apr 29, 2016 10:54 am

Sklipnott wrote:I spoke too early the other day indeed:
Sklipnott wrote:I can confirm those registry tweaks worked indeed.
Those scripts won't work on different machines. Unfortunately I don't have scripting skills to fix them. Please provide a solution.
A user (Syrinx) in contributing to working on this, and it will be reviewed by us. There is no ETA at this time.

Craig@Invincea
Sandboxie Support
Sandboxie Support
Posts: 3523
Joined: Thu Jun 18, 2015 3:00 pm
Location: DC Metro Area

Re: Office 2013 non C2R & Excel work around.

Post by Craig@Invincea » Fri Apr 29, 2016 11:04 am

This batch file by @Syrinx w/ the assistance of @MrX should help!

Code: Select all

@echo off
reg.exe export "HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open" %~dp0Export8.reg
cmd /a /c type %~dp0Export8.reg > %~dp0Export8A.reg
reg.exe export "HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open" %~dp0Export12.reg
cmd /a /c type %~dp0Export12.reg > %~dp0Export12A.reg

set "ExcelVariable= \"%%1\""

set "Original8=2F,00,64,00,64,00,65"
set "Fix8=22,00,25,00,31,00,22"
set "source=%~dp0Export8A.reg"
set "target=%~dp0Fix8.reg"
setlocal enableDelayedExpansion
(
  for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %source%') do (
  set "line=%%b"
  if defined line set "line=!line:%Original8%=%Fix8%!"
  echo(!line!
  )
) > %target%
endlocal

set "DDE8= /dde"
set "F8=%ExcelVariable%"
set "source=%~dp0Fix8.reg"
set "target=%~dp0Fix8B.reg"
setlocal enableDelayedExpansion
(
  for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %source%') do (
  set "line=%%b"
  if defined line set "line=!line:%DDE8%=%F8%!"
  echo(!line!
  )
) > %target%
endlocal

set "Original12=2F,00,64,00,64,00,65"
set "Fix12=22,00,25,00,31,00,22"
set "source=%~dp0Export12A.reg"
set "target=%~dp0Fix12.reg"
setlocal enableDelayedExpansion
(
  for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %source%') do (
  set "line=%%b"
  if defined line set "line=!line:%Original12%=%Fix12%!"
  echo(!line!
  )
) > %target%
endlocal

set "DDE12= /dde"
set "F12=%ExcelVariable%"
set "source=%~dp0Fix12.reg"
set "target=%~dp0Fix12B.reg"
setlocal enableDelayedExpansion
(
  for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %source%') do (
  set "line=%%b"
  if defined line set "line=!line:%DDE12%=%F12%!"
  echo(!line!
  )
) > %target%
endlocal
regedit /s "%~dp0Fix8B.reg"
regedit /s "%~dp0Fix12B.reg"
del %~dp0Export8A.reg
del %~dp0Export12A.reg
del %~dp0Fix8.reg
del %~dp0Fix12.reg
del %~dp0Fix8B.reg
del %~dp0Fix12B.reg
REG DELETE HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\ddeexec /f
REG DELETE HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\ddeexec /f

Syrinx
Sandboxie Guru
Sandboxie Guru
Posts: 621
Joined: Fri Nov 13, 2015 4:11 pm

Re: Office 2013 non C2R & Excel work around.

Post by Syrinx » Mon Jul 25, 2016 1:36 pm

Already posted this elsewhere but I hunted it down and am re-posting it here because a couple people mentioned having the same trouble with word documents on some versions of Office and it'd be better to consolidate them I think.

This one is for Word, the one for excel is still posted above:

Code: Select all

    @echo off
    reg.exe export "HKEY_CLASSES_ROOT\Word.Document.8\shell\Open" %~dp0Export8.reg
    cmd /a /c type %~dp0Export8.reg > %~dp0Export8A.reg
    reg.exe export "HKEY_CLASSES_ROOT\Word.Document.12\shell\Open" %~dp0Export12.reg
    cmd /a /c type %~dp0Export12.reg > %~dp0Export12A.reg

    set "WordVariable= \"%%1\""

    set "Original8=2F,00,64,00,64,00,65"
    set "Fix8=22,00,25,00,31,00,22"
    set "source=%~dp0Export8A.reg"
    set "target=%~dp0Fix8.reg"
    setlocal enableDelayedExpansion
    (
       for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %source%') do (
          set "line=%%b"
          if defined line set "line=!line:%Original8%=%Fix8%!"
          echo(!line!
       )
    ) > %target%
    endlocal

    set "DDE8= /dde"
    set "F8=%WordVariable%"
    set "source=%~dp0Fix8.reg"
    set "target=%~dp0Fix8B.reg"
    setlocal enableDelayedExpansion
    (
       for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %source%') do (
          set "line=%%b"
          if defined line set "line=!line:%DDE8%=%F8%!"
          echo(!line!
       )
    ) > %target%
    endlocal

    set "Original12=2F,00,64,00,64,00,65"
    set "Fix12=22,00,25,00,31,00,22"
    set "source=%~dp0Export12A.reg"
    set "target=%~dp0Fix12.reg"
    setlocal enableDelayedExpansion
    (
       for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %source%') do (
          set "line=%%b"
          if defined line set "line=!line:%Original12%=%Fix12%!"
          echo(!line!
       )
    ) > %target%
    endlocal

    set "DDE12= /dde"
    set "F12=%WordVariable%"
    set "source=%~dp0Fix12.reg"
    set "target=%~dp0Fix12B.reg"
    setlocal enableDelayedExpansion
    (
       for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %source%') do (
          set "line=%%b"
          if defined line set "line=!line:%DDE12%=%F12%!"
          echo(!line!
       )
    ) > %target%
    endlocal

    regedit /s "%~dp0Fix8B.reg"
    regedit /s "%~dp0Fix12B.reg"
    del %~dp0Export8A.reg
    del %~dp0Export12A.reg
    del %~dp0Fix8.reg
    del %~dp0Fix12.reg
    del %~dp0Fix8B.reg
    del %~dp0Fix12B.reg
    REG DELETE HKEY_CLASSES_ROOT\Word.Document.8\shell\Open\ddeexec /f
    REG DELETE HKEY_CLASSES_ROOT\Word.Document.12\shell\Open\ddeexec /f
Also, just like Excel, there are separate entries for macro enabled documents which this doesn't touch but either can be modified with a search and replace for all inside notepad to change those as well. eg
"Word.Document." replaced with "Word.DocumentMacroEnabled."
and
"Excel.Sheet." replaced with "Excel.SheetMacroEnabled." for the registry key locations
http://goo.gl/p8qFCf
https://www.youtube.com/watch?v=vIxWgVOCexU

Syrinx
Sandboxie Guru
Sandboxie Guru
Posts: 621
Joined: Fri Nov 13, 2015 4:11 pm

Re: Office 2013 non C2R & Excel work around.

Post by Syrinx » Sun Jul 31, 2016 5:48 pm

There were a couple of issues with the previous bat concerning paths with a space in them....
Previously the scripts posted for Excel and Word only fixed the 'Open' keys for:

Excel.Sheet.12
Excel.Sheet.8
or
Word.Document.12
Word.Document.8

So here's a new script that attempts to fix not only the 'Open' keys but also the entries for Edit, New, OpenAsReadOnly, Print, and ViewProtected for:
Excel.Backup
Excel.Chart
Excel.CSV
Excel.Macrosheet
Excel.OpenDocumentSpreadsheet.12
Excel.Sheet.12
Excel.Sheet.8
Excel.SheetBinaryMacroEnabled.12
Excel.SheetMacroEnabled.12
Excel.Template
Excel.Template.8
Excel.TemplateMacroEnabled
Word.Backup.8
Word.Document.12
Word.Document.8
Word.DocumentMacroEnabled.12
Word.DocumentMacroEnabled.8
Word.RTF.8
Word.Template.12
Word.Template.8
Word.TemplateMacroEnabled.12
Word.TemplateMacroEnabled.8

This should result in an easier 'alert/error free' experience between Office and SBIE where previously a user might have been getting annoying errors upon opening a document or spreadsheet before the program was loaded and protected within SBIE and being left with nothing but the program opened.
I can't guarantee it will fix all of the potential entries or possible alerts but if it happens to involve the /dde string (eg there was a problem sending the command to the program) there's a good chance this will do it for you.

If you have the same issue with anything other than Excel or Word please let me know as this bat still doesn't cover anything else.

Here's the new .bat code. You can copy it all into a .txt (eg in notepad) then rename it to bat. [May need to ensure known file extensions are shown in explorer]
It will need to be run as Admin due to the fact the registry entries it needs to change are located in the HKCR hive.

Code: Select all

@ECHO OFF
TITLE EULA: Don't blame me!

SET DONE=0
IF EXIST "%~DP0Office\EULA.txt" GOTO INIT
IF EXIST "%~DP0\EULA.txt" GOTO INIT
:PROMPT
ECHO This bat will modify your registry! [Office Related]
ECHO.
ECHO This bat was made by a user in an effort to aid other users.
ECHO.
ECHO The author does NOT make any warranty of any kind,
ECHO either express or implied. In no event shall the author of this
ECHO bat be liable for any consequential, direct, incidental
ECHO or indirect damages (including, without limitation,
ECHO damages for loss of business profits, business interruption,
ECHO loss of business information, destruction of the universe
ECHO or any other loss) arising from the use of this bat.
ECHO.
ECHO Do you agree to these terms?
ECHO (Y for Yes, N for No)
ECHO.
SET /P CHOICE=    ^   Make your Choice: 
SET CHOICE=%CHOICE:~0,1%
IF /I "%CHOICE%"=="Y" GOTO INIT
IF /I "%CHOICE%"=="N" EXIT
CLS
ECHO Oops, please try again!
ECHO.
GOTO PROMPT

:INIT
CLS
ECHO Checking Access Level...
IF EXIST %WINDIR%\AdminTest (
	RMDIR %WINDIR%\AdminTest /Q /S 1>NUL 2>NUL
	GOTO TEST
)
IF NOT EXIST %WINDIR%\AdminTest MD %WINDIR%\AdminTest 1>NUL 2>NUL
:TEST
IF %ERRORLEVEL%==0 (
	IF EXIST %WINDIR%\AdminTest RMDIR %WINDIR%\AdminTest  /Q /S 1>NUL 2>NUL
	ECHO Seems to be running as Admin, continuing...
	GOTO SELECTION
)
ECHO.
ECHO Sorry, it won't work if you don't (Right click the bat and)
ECHO Run as administrator
GOTO END

:SELECTION
SET /A AUTORESTORE=0
TITLE What are you doing?
ECHO.
ECHO **This bat will modify Office related registry entries!**
ECHO.
ECHO Choose 1 to Backup and Replace /dde
ECHO Choose 2 to Restore /dde using Backups
ECHO Choose 3 to Cancel and Exit.
ECHO.
ECHO **This bat will modify Office related registry entries!**
ECHO.
SET /P SELECTION=    ^   Which option number would you like to try?: 
SET SELECTION=%SELECTION:~0,1%
IF /I "%SELECTION%"=="1" GOTO ROUND_1
IF /I "%SELECTION%"=="2" GOTO ROUND_7
IF /I "%SELECTION%"=="3" EXIT
CLS
ECHO Oops, please try again!
ECHO.
GOTO SELECTION

:CYCLE
IF %NUMBER%==1 SET CURRENTTARGET=Excel.Backup
IF %NUMBER%==2 SET CURRENTTARGET=Excel.Chart
IF %NUMBER%==3 SET CURRENTTARGET=Excel.CSV
IF %NUMBER%==4 SET CURRENTTARGET=Excel.Macrosheet
IF %NUMBER%==5 SET CURRENTTARGET=Excel.OpenDocumentSpreadsheet.12
IF %NUMBER%==6 SET CURRENTTARGET=Excel.Sheet.12
IF %NUMBER%==7 SET CURRENTTARGET=Excel.Sheet.8
IF %NUMBER%==8 SET CURRENTTARGET=Excel.SheetBinaryMacroEnabled.12
IF %NUMBER%==9 SET CURRENTTARGET=Excel.SheetMacroEnabled.12
IF %NUMBER%==10 SET CURRENTTARGET=Excel.Template
IF %NUMBER%==11 SET CURRENTTARGET=Excel.Template.8
IF %NUMBER%==12 SET CURRENTTARGET=Excel.TemplateMacroEnabled
IF %NUMBER%==13 SET CURRENTTARGET=Word.Backup.8
IF %NUMBER%==14 SET CURRENTTARGET=Word.Document.12
IF %NUMBER%==15 SET CURRENTTARGET=Word.Document.8
IF %NUMBER%==16 SET CURRENTTARGET=Word.DocumentMacroEnabled.12
IF %NUMBER%==17 SET CURRENTTARGET=Word.DocumentMacroEnabled.8
IF %NUMBER%==18 SET CURRENTTARGET=Word.RTF.8
IF %NUMBER%==19 SET CURRENTTARGET=Word.Template.12
IF %NUMBER%==20 SET CURRENTTARGET=Word.Template.8
IF %NUMBER%==21 SET CURRENTTARGET=Word.TemplateMacroEnabled.12
IF %NUMBER%==22 SET CURRENTTARGET=Word.TemplateMacroEnabled.8
IF %NUMBER% GEQ 23 GOTO CHECKROUND
SET /A NUMBER=NUMBER+1
IF %AUTORESTORE%==0 GOTO EDIT
IF %AUTORESTORE%==1 GOTO AUTORESTORE1
GOTO ERROR

:EDIT
SET /A ROUNDPREV=%ROUNDNUM%-1
reg QUERY "HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell\Print\ddeexec" 1>nul 2>nul
if %errorlevel%==5 goto SECURITY
if %errorlevel%==1 goto CYCLE
IF NOT EXIST "%~DP0Office\%CURRENTTARGET%.reg" regedit /A "%~DP0Office\%CURRENTTARGET%.reg" "HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell"
IF NOT EXIST "%~DP0Office\%CURRENTTARGET%.reg" GOTO CYCLE
IF %ROUNDNUM%==1 (
	IF EXIST "%~DP0Office\%CURRENTTARGET%.reg" (
		SET "SOURCE=%~DP0Office\%CURRENTTARGET%.reg"
		SET "TARGET=%~DP0Office\Temp\%CURRENTTARGET%.Fixing.%ROUNDNUM%.reg"
		GOTO REPLACE
	)
)
IF NOT EXIST "%~DP0Office\Temp\%CURRENTTARGET%.Fixing.%ROUNDPREV%.reg" GOTO CYCLE
SET "SOURCE=%~DP0Office\Temp\%CURRENTTARGET%.Fixing.%ROUNDPREV%.reg"
IF %ROUNDNUM% LEQ 5 (
	SET "TARGET=%~DP0Office\Temp\%CURRENTTARGET%.Fixing.%ROUNDNUM%.reg"
	GOTO REPLACE
)
IF %ROUNDNUM% EQU 6 (
	SET "TARGET=%~DP0Office\Fix\%CURRENTTARGET%.Fixed.reg"
	GOTO REPLACE
)
GOTO CYCLE

:CHECKROUND
SET /A ROUNDNUM=ROUNDNUM+1
IF %ROUNDNUM% LEQ 6 (
	SET /A NUMBER=1
	GOTO Round_%ROUNDNUM%
)
IF %ROUNDNUM% GEQ 7 GOTO END
GOTO ERROR

:REPLACE
SETLOCAL ENABLEDELAYEDEXPANSION
(
	FOR /F "tokens=1* delims=:" %%A IN ('findstr /N "^" "%SOURCE%"') DO (
		SET "LINE=%%B"
		IF DEFINED LINE SET "LINE=!LINE:%ORIGINAL%=%FIX%!"
		ECHO(!LINE!
	)
) > "%TARGET%"
ENDLOCAL
IF EXIST "%~DP0Office\Fix\%CURRENTTARGET%.Fixed.reg" (
	regedit /S "%~DP0Office\Fix\%CURRENTTARGET%.Fixed.reg"
	IF %ERRORLEVEL%==5 GOTO SECURITY
	reg DELETE HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell\Edit\ddeexec /f 1>NUL 2>NUL
	reg DELETE HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell\New\ddeexec /f 1>NUL 2>NUL
	reg DELETE HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell\OnenotePrintto\ddeexec /f 1>NUL 2>NUL
	reg DELETE HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell\Open\ddeexec /f 1>NUL 2>NUL
	reg DELETE HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell\OpenAsReadOnly\ddeexec /f 1>NUL 2>NUL
	reg DELETE HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell\Print\ddeexec /f 1>NUL 2>NUL
	reg DELETE HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell\Printto\ddeexec /f 1>NUL 2>NUL
	reg DELETE HKEY_CLASSES_ROOT\%CURRENTTARGET%\shell\ViewProtected\ddeexec /f 1>NUL 2>NUL
	SET /A DONE=DONE+1
)
GOTO CYCLE

:ROUND_1
TITLE Replace /dde
CLS
ECHO.
ECHO Starting Pass 1 (This should be quick)
IF NOT EXIST "%~DP0Office" MD "%~DP0Office" 1>NUL
IF NOT EXIST "%~DP0Office\Fix" MD "%~DP0Office\Fix" 1>NUL
IF NOT EXIST "%~DP0Office\Temp" MD "%~DP0Office\Temp" 1>NUL
IF NOT EXIST "%~DP0Office\EULA.txt" (
	IF NOT EXIST "%~DP0\EULA.txt" (
		TYPE NUL > "%~DP0Office\EULA.txt"
)
SET /A ROUNDNUM=1
SET /A NUMBER=1
SET "ORIGINAL= /dde"
SET "FIX= \"%%1\""
GOTO CYCLE

:ROUND_2
ECHO.
ECHO Starting Pass 2 (This may take a bit)
COPY /Y "%~0" "%~DP0Office\BACKUP.bat" 1>NUL 2>NUL
SET "ORIGINAL=2f,64,64,65"
SET "FIX=22,25,31,22"
GOTO CYCLE

:ROUND_3
ECHO .
SET "ORIGINAL=2f,64,64"
SET "FIX=22,25,31"
GOTO CYCLE

:ROUND_4
ECHO ..
SET "ORIGINAL=  65,00,00"
SET "FIX=  22,00,00"
GOTO CYCLE

:ROUND_5
ECHO ...
SET "ORIGINAL=2f,64"
SET "FIX=22,25"
GOTO CYCLE

:ROUND_6
ECHO ....
SET "ORIGINAL=  64,65,00,00"
SET "FIX=  31,22,00,00"
GOTO CYCLE

:ROUND_7
CLS
ECHO.
ECHO Attempting to restore Original registry backups.
SET /A AUTORESTORE=1
SET /A ROUNDNUM=7
SET /A NUMBER=1
GOTO CYCLE

:AUTORESTORE1
IF EXIST "%~DP0Office\%CURRENTTARGET%.reg" (
	regedit /S "%~DP0Office\%CURRENTTARGET%.reg"
	SET /A DONE=DONE+1
)
IF EXIST "%~DP0%CURRENTTARGET%.reg" (
	regedit /S "%~DP0%CURRENTTARGET%.reg"
	SET /A DONE=DONE+1
)
GOTO CYCLE

:SECURITY
ECHO.
ECHO Sorry, it looks like some security program is preventing
ECHO access to needed programs or locations
ECHO (eg %SYSTEMROOT%\system32\reg.exe or regedit.exe etc or HKCR)
ECHO.
ECHO Please try disabling the product and run the bat again!
IF NOT EXIST "%~DP0Office\%CURRENTTARGET%.reg" RMDIR "%~DP0Office" /Q /S
GOTO END

:ERROR
ECHO :( Oops Your PC ran into a problem that it couldn't
ECHO handle, then it asked a question.
ECHO.
ECHO "Shall we play a game?"
ECHO.
ECHO I told it "NO" for you but then it got mad and broke this BAT.
ECHO.
ECHO Better go and complain now!
ECHO http://forums.sandboxie.com/phpBB3/viewtopic.php?f=22^&t=22829
ECHO.
GOTO END

:END
TITLE !!KEEP OFFICE FOLDER!!
ECHO.
ECHO -----------------------------------------------------------------------------
RMDIR "%~DP0Office\Fix" /Q /S 1>NUL 2>NUL
RMDIR "%~DP0Office\Temp" /Q /S 1>NUL 2>NUL
IF %DONE%==0 ECHO Oops! It looks like nothing changed.
ECHO %DONE% registry locations processed.
IF %DONE%==0 GOTO NOFOLDER
ECHO.
ECHO !KEEP a copy of the new "Office" folder!
ECHO It contains the files needed to restore the original entries.
ECHO.
ECHO This new "Office" folder will be in the same location as the bat.
:NOFOLDER
ECHO -----------------------------------------------------------------------------
ECHO.
ECHO Press any key to exit...
PAUSE 1>NUL
EXIT
Upon completing there will be a new folder labeled "Office" in the same location that the bat is launched from.
It is VERY IMPORTANT that you KEEP a copy of this folder someplace. It retains the original registry entries in case you need to restore them (undo this bat).

If you're having trouble getting the code above into a bat or you just want to download it, here's the same code inside a ready to launch .bat
http://www.mediafire.com/download/ona7q ... ce_DDE.bat
http://www107.zippyshare.com/v/lVIaJMaU/file.html

I spent a good chunk of this past weeks free time working on this one and tried to make it more resilient but there is a chance that it still has a couple bugs. It's also not the prettiest or most optimized bat ever created but being a newb I think it turned out pretty well. Still, if you have any issues or suggestions, feel free to let me know.
http://goo.gl/p8qFCf
https://www.youtube.com/watch?v=vIxWgVOCexU

Mr.X
Posts: 595
Joined: Sat Jul 13, 2013 9:34 am
Location: Mexico

Re: Office 2013 non C2R & Excel work around.

Post by Mr.X » Sun Jul 31, 2016 7:42 pm

@syrinx

As usual, you did a spectacular job. Thanks a lot.
Windows 8.1 x64 EN | Sandboxie latest beta or stable | All software latest versions unless stated otherwise

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest