[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[注册表类] [已解决]怎样将注册表项用批处理变量替代并导出注册表呢?

本帖最后由 867258173 于 2015-1-27 22:36 编辑

请问怎样用批处理变量替代【S-1-5-21-3280445496-1143160547-4056481177-1001】导出注册表,根据电脑不同,这个好像不通用,再别的电脑注册【S-1-5-21-3280445496-1143160547-4056481177-1001】
就会注册失败?
下面是注册表试例?在自己电脑上将注册表就算全卸载了,exe主程序还是能打开。但在别的电脑就会提示安装不完全,意思就是注册表没导入。所以才无法打开。使用注册表改路径也是提示【导入失败】,我1个个注册表项试了,在别的电脑[HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001就是这导入不进去,一直失败,但要是无法导入,exe主程序也就无法打开。所以请教下,怎样用批处理变量根据所在电脑不同来代替【S-1-5-21-3280445496-1143160547-4056481177-1001】导入注册表呢?
  1. Windows Registry Editor Version 5.00
  2. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FW_Grisaia]
  3. "DisplayName"="グリザイアの果実"
  4. "UninstallString"="D:\\グリザイアの果実\\uninst.exe"
  5. [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\e6e542c2_0]
  6. @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume1\\frontwing\\グリザイアの果実\\Grisaia.exeb{00000000-0000-0000-0000-000000000000}"
  7. [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\e6e542c2_0\{219ED5A0-9CBF-4F3A-B927-37C9E5C5F14F}]
  8. "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3F,00,00,00,00
  9. "4"=hex:04,20,00,00,00,00,00,00,10,00,00,00,00,00,00,00,00,00,80,3F,00,00,80,\
  10.   3F
  11. "5"=hex:0B,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
  12. [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count]
  13. "P:\\sebagjvat\\グリザイアの果実\\Tevfnvn.rkr"=hex:03,00,00,00,01,00,00,00,03,00,00,00,\
  14.   5D,05,00,00,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,\
  15.   00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,FF,FF,FF,FF,70,F0,\
  16.   C4,73,14,30,D0,01,00,00,00,00
  17. [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\Count]
  18. "P:\\Hfref\\QZFW\\Qrfxgbc\\グリザイアの果実.yax"=hex:03,00,00,00,01,00,00,00,00,00,00,\
  19.   00,01,00,00,00,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,\
  20.   00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,FF,FF,FF,FF,80,\
  21.   17,C5,73,14,30,D0,01,00,00,00,00
  22. [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\SogouInput.user]
  23. "CheckFastpassport"=dword:54B694FA
  24. "LastLoad"=dword:54B5CC18
  25. "SogouComponentFirstLoad"=dword:54B694BA
  26. "SogouComponentFirstRun"=dword:54B674D0
  27. "Used"=dword:54B694BA
复制代码
1

评分人数

    • Batcher: 感谢给帖子标题标注[已解决]字样PB + 2

回复 1# 867258173

问题是[S-1-5-21-3280445496-1143160547-4056481177-1001]是怎么生成的?
你是先安装了软件,然后在注册表自动生成这个项?还是原本有个reg文件要先导入注册表?

TOP

首先你搞清楚 S-1-5-21-3280445496-1143160547-4056481177-1001 这个字符串是根据什么计算出来的,否则无法写代码。

TOP

查找当前用户对应的SID
  1. @echo off & setlocal enabledelayedexpansion
  2. set "k=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
  3. for /f "delims=" %%i in ('reg query "%k%" /s') do (
  4.     set "s=%%i"
  5.     if defined SID (
  6.         for /f "tokens=1,2*" %%a in ("%%i") do (
  7.             if /i "%%a" == "ProfileImagePath" (
  8.                 if /i "%%~nxc" == "%userName%" goto :Next
  9.                 set "SID="
  10.             )
  11.         )
  12.     ) else if /i "!s:~,5!" == "HKEY_" set "SID=%%~nxi"
  13. )
  14. :Next
  15. echo,%SID%
  16. pause
复制代码

TOP

回复 4# apang


   对,看来就是在用户对应的SID生成注册表才能打开exe程序。请问怎样在批处理判断当前电脑SID,然后替换下面【S-1-5-21-3280445496-1143160547-4056481177-1001】导出注册表呢?
  1. SET renchongyi=%CD%
  2. SET renchongyi=%renchongyi:\=\\%
  3. >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
  4. >>".\regfile.reg" ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FW_Grisaia]
  5. >>".\regfile.reg" ECHO "DisplayName"="グリザイアの果実"
  6. >>".\regfile.reg" ECHO "UninstallString"="%renchongyi%\\uninst.exe"
  7. >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\e6e542c2_0]
  8. >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count]
  9. >>".\regfile.reg" ECHO "P:\\sebagjvat\\グリザイアの果実\\Tevfnvn.rkr"=hex:03,00,00,00,01,00,00,00,03,00,00,00,\
  10. >>".\regfile.reg" ECHO   5D,05,00,00,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,\
  11. >>".\regfile.reg" ECHO   00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,FF,FF,FF,FF,70,F0,\
  12. >>".\regfile.reg" ECHO   C4,73,14,30,D0,01,00,00,00,00
  13. >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\Count]
  14. >>".\regfile.reg" ECHO "P:\\Hfref\\QZFW\\Qrfxgbc\\グリザイアの果実.yax"=hex:03,00,00,00,01,00,00,00,00,00,00,\
  15. >>".\regfile.reg" ECHO   00,01,00,00,00,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,\
  16. >>".\regfile.reg" ECHO   00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,FF,FF,FF,FF,80,\
  17. >>".\regfile.reg" ECHO   17,C5,73,14,30,D0,01,00,00,00,00
  18. >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\SogouInput.user]
  19. >>".\regfile.reg" ECHO "CheckFastpassport"=dword:54B694FA
  20. >>".\regfile.reg" ECHO "LastLoad"=dword:54B5CC18
  21. >>".\regfile.reg" ECHO "SogouComponentFirstLoad"=dword:54B694BA
  22. >>".\regfile.reg" ECHO "SogouComponentFirstRun"=dword:54B674D0
  23. >>".\regfile.reg" ECHO "Used"=dword:54B694BA
  24. >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
  25. >>".\regfile.reg" ECHO [HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
  26. >>".\regfile.reg" ECHO "LangID"=hex:04,08
  27. >>".\regfile.reg" ECHO "%renchongyi%\\Grisaia.exe"="cs2"Windows Registry Editor Version 5.00
  28. >>".\regfile.reg" ECHO [HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
  29. >>".\regfile.reg" ECHO "LangID"=hex:04,08
  30. >>".\regfile.reg" ECHO "%renchongyi%\\Grisaia.exe"="cs2"
  31. >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
  32. >>".\regfile.reg" ECHO [HKEY_CURRENT_USER\Software\Microsoft\DirectInput\MostRecentApplication]
  33. >>".\regfile.reg" ECHO "Name"="GRISAIA.EXE"
  34. >>".\regfile.reg" ECHO "Id"="GRISAIA.EXE4D4EA7DF00383000"
  35. >>".\regfile.reg" ECHO "Version"=hex:0a,05,00,00
  36. >>".\regfile.reg" ECHO "MostRecentStart"=hex:3a,7c,54,29,48,36,d0,01
  37. >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
  38. >>".\regfile.reg" ECHO [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0]
  39. >>".\regfile.reg" ECHO @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume2\\グリザイアの果実\\Grisaia.exe%b{00000000-0000-0000-0000-000000000000}"
  40. >>".\regfile.reg" ECHO [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0\{219ED5A0-9CBF-4F3A-B927-37C9E5C5F14F}]
  41. >>".\regfile.reg" ECHO "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3f,00,00,00,00
  42. >>".\regfile.reg" ECHO "4"=hex:04,20,00,00,00,00,00,00,10,00,00,00,00,00,00,00,00,00,80,3f,00,00,80,\
  43. >>".\regfile.reg" ECHO   3f
  44. >>".\regfile.reg" ECHO "5"=hex:0b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
  45. >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
  46. >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
  47. >>".\regfile.reg" ECHO "LangID"=hex:04,08
  48. >>".\regfile.reg" ECHO "%renchongyi%\\Grisaia.exe"="cs2"
  49. >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
  50. >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\DirectInput\MostRecentApplication]
  51. >>".\regfile.reg" ECHO "Name"="GRISAIA.EXE"
  52. >>".\regfile.reg" ECHO "Id"="GRISAIA.EXE4D4EA7DF00383000"
  53. >>".\regfile.reg" ECHO "Version"=hex:0a,05,00,00
  54. >>".\regfile.reg" ECHO "MostRecentStart"=hex:3a,7c,54,29,48,36,d0,01
  55. >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
  56. >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0]
  57. >>".\regfile.reg" ECHO @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume2\\グリザイアの果実\\Grisaia.exe%b{00000000-0000-0000-0000-000000000000}"
  58. >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0\{219ED5A0-9CBF-4F3A-B927-37C9E5C5F14F}]
  59. >>".\regfile.reg" ECHO "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3f,00,00,00,00
  60. >>".\regfile.reg" ECHO "4"=hex:04,20,00,00,00,00,00,00,10,00,00,00,00,00,00,00,00,00,80,3f,00,00,80,\
  61. >>".\regfile.reg" ECHO   3f
  62. >>".\regfile.reg" ECHO "5"=hex:0b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
  63. >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
  64. >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001_Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
  65. >>".\regfile.reg" ECHO "LangID"=hex:04,08
  66. >>".\regfile.reg" ECHO "%renchongyi%\\Grisaia.exe"="cs2"
复制代码

TOP

本帖最后由 apang 于 2015-1-27 21:52 编辑
  1. @echo off & setlocal enabledelayedexpansion
  2. set "k=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
  3. for /f "tokens=*" %%i in ('reg query "%k%" /s') do (
  4.         set "s=%%i"
  5.         if /i "!s:~,5!" == "HKEY_" set "SID=%%~nxi"
  6.         if /i "!s:~,16!" == "ProfileImagePath" (
  7.                 if /i "%%~nxi" == "%userName%" goto :Next
  8.         )
  9. )
  10. :Next
  11. SET "renchongyi=%~dp0"
  12. SET "renchongyi=%renchongyi:\=\\%"
  13. (for /f "delims=:" %%i in ('findstr /nb :dynamicScript "%~0"') do (
  14.         for /f "delims=" %%a in ('more +%%i "%~0"') do (
  15.                 set "s=%%a"
  16.                 set "s=!s:\##=\%SID%!"
  17.                 set "s=!s:$$\\=%renchongyi%!"
  18.                 echo,!s!
  19.         )
  20. ))>1.reg
  21. pause & exit/b
  22. :dynamicScript
  23. Windows Registry Editor Version 5.00
  24. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FW_Grisaia]
  25. "DisplayName"="グリザイアの果実"
  26. "UninstallString"="$$\\uninst.exe"
  27. [HKEY_USERS\##\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\e6e542c2_0]
  28. [HKEY_USERS\##\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count]
  29. "P:\\sebagjvat\\グリザイアの果実\\Tevfnvn.rkr"=hex:03,00,00,00,01,00,00,00,03,00,00,00,\
  30.    5D,05,00,00,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,\
  31.    00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,FF,FF,FF,FF,70,F0,\
  32.    C4,73,14,30,D0,01,00,00,00,00
  33. [HKEY_USERS\##\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\Count]
  34. "P:\\Hfref\\QZFW\\Qrfxgbc\\グリザイアの果実.yax"=hex:03,00,00,00,01,00,00,00,00,00,00,\
  35.    00,01,00,00,00,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,\
  36.    00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,FF,FF,FF,FF,80,\
  37.    17,C5,73,14,30,D0,01,00,00,00,00
  38. [HKEY_USERS\##\Software\SogouInput.user]
  39. "CheckFastpassport"=dword:54B694FA
  40. "LastLoad"=dword:54B5CC18
  41. "SogouComponentFirstLoad"=dword:54B694BA
  42. "SogouComponentFirstRun"=dword:54B674D0
  43. "Used"=dword:54B694BA
  44. Windows Registry Editor Version 5.00
  45. [HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
  46. "LangID"=hex:04,08
  47. "$$\\Grisaia.exe"="cs2"Windows Registry Editor Version 5.00
  48. [HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
  49. "LangID"=hex:04,08
  50. "$$\\Grisaia.exe"="cs2"
  51. Windows Registry Editor Version 5.00
  52. [HKEY_CURRENT_USER\Software\Microsoft\DirectInput\MostRecentApplication]
  53. "Name"="GRISAIA.EXE"
  54. "Id"="GRISAIA.EXE4D4EA7DF00383000"
  55. "Version"=hex:0a,05,00,00
  56. "MostRecentStart"=hex:3a,7c,54,29,48,36,d0,01
  57. Windows Registry Editor Version 5.00
  58. [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0]
  59. @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume2\\グリザイアの果実\\Grisaia.exe%b{00000000-0000-0000-0000-000000000000}"
  60. [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0\{219ED5A0-9CBF-4F3A-B927-37C9E5C5F14F}]
  61. "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3f,00,00,00,00
  62. "4"=hex:04,20,00,00,00,00,00,00,10,00,00,00,00,00,00,00,00,00,80,3f,00,00,80,\
  63.    3f
  64. "5"=hex:0b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
  65. Windows Registry Editor Version 5.00
  66. [HKEY_USERS\##\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
  67. "LangID"=hex:04,08
  68. "$$\\Grisaia.exe"="cs2"
  69. Windows Registry Editor Version 5.00
  70. [HKEY_USERS\##\Software\Microsoft\DirectInput\MostRecentApplication]
  71. "Name"="GRISAIA.EXE"
  72. "Id"="GRISAIA.EXE4D4EA7DF00383000"
  73. "Version"=hex:0a,05,00,00
  74. "MostRecentStart"=hex:3a,7c,54,29,48,36,d0,01
  75. Windows Registry Editor Version 5.00
  76. [HKEY_USERS\##\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0]
  77. @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume2\\グリザイアの果実\\Grisaia.exe%b{00000000-0000-0000-0000-000000000000}"
  78. [HKEY_USERS\##\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0\{219ED5A0-9CBF-4F3A-B927-37C9E5C5F14F}]
  79. "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3f,00,00,00,00
  80. "4"=hex:04,20,00,00,00,00,00,00,10,00,00,00,00,00,00,00,00,00,80,3f,00,00,80,\
  81.   3f
  82. "5"=hex:0b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
  83. Windows Registry Editor Version 5.00
  84. [HKEY_USERS\##_Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
  85. "LangID"=hex:04,08
  86. "$$\\Grisaia.exe"="cs2"
复制代码
1

评分人数

TOP

本帖最后由 867258173 于 2015-1-27 20:40 编辑

回复 6# apang


   谢谢,这个刚在笔记本上试了下,SID更改成功了,但有一个问题,这样导出注册表后,%renchongyi%就无效了。导出注册表目的是为了查看是否正确,最终还是要导入注册表。但%renchongyi%代表当前路径的变量无效了,那导入注册表也是无效。希望你能把这代码再改一下,能够在样导出注册表后,不但SID更改,%renchongyi%也能够使用导出当前路径到注册表,最后导入。麻烦您了

TOP

回复 7# 867258173


    已修改

TOP

回复 8# apang


    谢谢

TOP

返回列表