I am trying to create virtual folder in navigation pane in windows explorer like OneDrive or Dropbox or Google Drive.
I have one batch file (i.e. script) which create registry entry at (HKCU) level which is working fine when i run it manually in command prompt. But it is not working when i am trying run same .bat file inside .onInstSuccess callback by electron-builder using nsis custom script. It is create only virtual folder link like xXxxxx (32 bit) in navigation pane but when you click on it nothing happen (it should open TargetFolderPath, which is mentioned in .bat file).
Following is my .bat file (add.bat).
@set uuid=f2b4cf36-0e3d-534a-9835-732a0139c194
@echo off
@reg add HKCU\Software\Classes\CLSID\{%uuid%} /ve /t REG_SZ /d "xXxxxx" /f
@reg add HKCU\Software\Classes\CLSID\{%uuid%}\DefaultIcon /ve /t REG_EXPAND_SZ /d "%SystemRoot%\system32\imageres.dll",-1043 /f
@reg add HKCU\Software\Classes\CLSID\{%uuid%} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x1 /f
@reg add HKCU\Software\Classes\CLSID\{%uuid%} /v SortOrderIndex /t REG_DWORD /d 0x42 /f
@reg add HKCU\Software\Classes\CLSID\{%uuid%}\InProcServer32 /ve /t REG_EXPAND_SZ /d "%SystemRoot%\system32\shell32.dll" /f
@reg add HKCU\Software\Classes\CLSID\{%uuid%}\Instance /v CLSID /t REG_SZ /d {0E5AAE11-A475-4c5b-AB00-C66DE400274E} /f
@reg add HKCU\Software\Classes\CLSID\{%uuid%}\Instance\InitPropertyBag /v Attributes /t REG_DWORD /d 0x11 /f
@reg add HKCU\Software\Classes\CLSID\{%uuid%}\Instance\InitPropertyBag /v TargetFolderPath /t REG_EXPAND_SZ /d "%USERPROFILE%\xXxxxx" /f
@reg add HKCU\Software\Classes\CLSID\{%uuid%}\ShellFolder /v FolderValueFlags /t REG_DWORD /d 0x28 /f
@reg add HKCU\Software\Classes\CLSID\{%uuid%}\ShellFolder /v Attributes /t REG_DWORD /d 0xF080004D /f
@reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{%uuid%} /ve /t REG_SZ /d xXxxxx /f
@reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v {%uuid%} /t REG_DWORD /d 0x1 /f
Following is my installer.nsh code
Function .onInstSuccess
; SetOutPath "$INSTDIR\resources\build\bin\"
ExpandEnvStrings $0 %COMSPEC%
; ExecWait '"$INSTDIR\resources\build\bin\add.bat"'
nsExec::Exec '"$0" /C if 1==1 "$INSTDIR\resources\build\bin\add.bat"'
FunctionEnd
I also attached two images of working.png and non-working.png virtual folder link in navigation pane for better clarity.
Note: I think there is an issue with nsExec::Exec, opened cmd.exe from .nsh file is not behave same like manually i ran .bat file in cmd.exe.
Thanks & Regards Rachit V. Sakhidas
Remember this is 32-bit NSIS, so by default the filesystem maps C:\Windows\System32 to C:\Windows\SysWOW64 and the registry maps HKCU\Software to HKCU\Software\Wow6432Node. So reg.exe is adding it to the wrong place, which is why you see the "(32-bit)" suffix. You could use the /reg:64 parameter, but there's no need to use reg.exe, since NSIS provides its own methods for registry modification.
Use something like: (sorry if there are any typos)
!define /redef uuid "{f2b4cf36-0e3d-534a-9835-732a0139c194}"
!define /redef clsid "Software\Classes\CLSID"
SetRegView 64
WriteRegStr HKCU "${clsid}\${uuid}" "" "xXxxxx"
WriteRegExpandStr HKCU "${clsid}\${uuid}\DefaultIcon" "" '"%SystemRoot%\system32\imageres.dll",-1043'
WriteRegDWORD HKCU "${clsid}\${uuid}" "System.IsPinnedToNameSpaceTree" 0x1
WriteRegDWORD HKCU "${clsid}\${uuid}" "SortOrderIndex" 0x42
WriteRegExpandStr HKCU "${clsid}\${uuid}\InProcServer32" "" '"%SystemRoot%\system32\shell32.dll"'
WriteRegStr HKCU "${clsid}\${uuid}\Instance" "CLSID" "{0E5AAE11-A475-4c5b-AB00-C66DE400274E}"
WriteRegDWORD HKCU "${clsid}\${uuid}\Instance\InitPropertyBag" "Attributes" 0x11
WriteRegExpandStr HKCU "${clsid}\${uuid}\Instance\InitPropertyBag" "TargetFolderPath" "%USERPROFILE%\xXxxxx"
WriteRegDWORD HKCU "${clsid}\${uuid}\ShellFolder" "FolderValueFlags" 0x28
WriteRegDWORD HKCU "${clsid}\${uuid}\ShellFolder" "Attributes" 0xF080004D
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\${uuid}" "" "xXxxxx"
WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" "${uuid}" 0x1
SetRegView lastused