标题: [注册表类] [已解决]怎样将注册表项用批处理变量替代并导出注册表呢? [打印本页]
作者: 867258173 时间: 2015-1-27 12:10 标题: [已解决]怎样将注册表项用批处理变量替代并导出注册表呢?
本帖最后由 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】导入注册表呢?- Windows Registry Editor Version 5.00
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FW_Grisaia]
- "DisplayName"="グリザイアの果実"
- "UninstallString"="D:\\グリザイアの果実\\uninst.exe"
- [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\e6e542c2_0]
- @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume1\\frontwing\\グリザイアの果実\\Grisaia.exeb{00000000-0000-0000-0000-000000000000}"
- [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}]
- "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3F,00,00,00,00
- "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,\
- 3F
- "5"=hex:0B,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count]
- "P:\\sebagjvat\\グリザイアの果実\\Tevfnvn.rkr"=hex:03,00,00,00,01,00,00,00,03,00,00,00,\
- 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,\
- 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,\
- C4,73,14,30,D0,01,00,00,00,00
- [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\Count]
- "P:\\Hfref\\QZFW\\Qrfxgbc\\グリザイアの果実.yax"=hex:03,00,00,00,01,00,00,00,00,00,00,\
- 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,\
- 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,C5,73,14,30,D0,01,00,00,00,00
- [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\SogouInput.user]
- "CheckFastpassport"=dword:54B694FA
- "LastLoad"=dword:54B5CC18
- "SogouComponentFirstLoad"=dword:54B694BA
- "SogouComponentFirstRun"=dword:54B674D0
- "Used"=dword:54B694BA
复制代码
作者: pcl_test 时间: 2015-1-27 13:13
回复 1# 867258173
问题是[S-1-5-21-3280445496-1143160547-4056481177-1001]是怎么生成的?
你是先安装了软件,然后在注册表自动生成这个项?还是原本有个reg文件要先导入注册表?
作者: DAIC 时间: 2015-1-27 13:26
首先你搞清楚 S-1-5-21-3280445496-1143160547-4056481177-1001 这个字符串是根据什么计算出来的,否则无法写代码。
作者: apang 时间: 2015-1-27 14:00
查找当前用户对应的SID- @echo off & setlocal enabledelayedexpansion
- set "k=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
- for /f "delims=" %%i in ('reg query "%k%" /s') do (
- set "s=%%i"
- if defined SID (
- for /f "tokens=1,2*" %%a in ("%%i") do (
- if /i "%%a" == "ProfileImagePath" (
- if /i "%%~nxc" == "%userName%" goto :Next
- set "SID="
- )
- )
- ) else if /i "!s:~,5!" == "HKEY_" set "SID=%%~nxi"
- )
-
- :Next
- echo,%SID%
- pause
复制代码
作者: 867258173 时间: 2015-1-27 16:10
回复 4# apang
对,看来就是在用户对应的SID生成注册表才能打开exe程序。请问怎样在批处理判断当前电脑SID,然后替换下面【S-1-5-21-3280445496-1143160547-4056481177-1001】导出注册表呢?- SET renchongyi=%CD%
- SET renchongyi=%renchongyi:\=\\%
- >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
- >>".\regfile.reg" ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FW_Grisaia]
- >>".\regfile.reg" ECHO "DisplayName"="グリザイアの果実"
- >>".\regfile.reg" ECHO "UninstallString"="%renchongyi%\\uninst.exe"
- >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\e6e542c2_0]
- >>".\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]
- >>".\regfile.reg" ECHO "P:\\sebagjvat\\グリザイアの果実\\Tevfnvn.rkr"=hex:03,00,00,00,01,00,00,00,03,00,00,00,\
- >>".\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,\
- >>".\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,\
- >>".\regfile.reg" ECHO C4,73,14,30,D0,01,00,00,00,00
- >>".\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]
- >>".\regfile.reg" ECHO "P:\\Hfref\\QZFW\\Qrfxgbc\\グリザイアの果実.yax"=hex:03,00,00,00,01,00,00,00,00,00,00,\
- >>".\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,\
- >>".\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,\
- >>".\regfile.reg" ECHO 17,C5,73,14,30,D0,01,00,00,00,00
- >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\SogouInput.user]
- >>".\regfile.reg" ECHO "CheckFastpassport"=dword:54B694FA
- >>".\regfile.reg" ECHO "LastLoad"=dword:54B5CC18
- >>".\regfile.reg" ECHO "SogouComponentFirstLoad"=dword:54B694BA
- >>".\regfile.reg" ECHO "SogouComponentFirstRun"=dword:54B674D0
- >>".\regfile.reg" ECHO "Used"=dword:54B694BA
- >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
- >>".\regfile.reg" ECHO [HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
- >>".\regfile.reg" ECHO "LangID"=hex:04,08
- >>".\regfile.reg" ECHO "%renchongyi%\\Grisaia.exe"="cs2"Windows Registry Editor Version 5.00
- >>".\regfile.reg" ECHO [HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
- >>".\regfile.reg" ECHO "LangID"=hex:04,08
- >>".\regfile.reg" ECHO "%renchongyi%\\Grisaia.exe"="cs2"
- >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
- >>".\regfile.reg" ECHO [HKEY_CURRENT_USER\Software\Microsoft\DirectInput\MostRecentApplication]
- >>".\regfile.reg" ECHO "Name"="GRISAIA.EXE"
- >>".\regfile.reg" ECHO "Id"="GRISAIA.EXE4D4EA7DF00383000"
- >>".\regfile.reg" ECHO "Version"=hex:0a,05,00,00
- >>".\regfile.reg" ECHO "MostRecentStart"=hex:3a,7c,54,29,48,36,d0,01
- >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
- >>".\regfile.reg" ECHO [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0]
- >>".\regfile.reg" ECHO @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume2\\グリザイアの果実\\Grisaia.exe%b{00000000-0000-0000-0000-000000000000}"
- >>".\regfile.reg" ECHO [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0\{219ED5A0-9CBF-4F3A-B927-37C9E5C5F14F}]
- >>".\regfile.reg" ECHO "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3f,00,00,00,00
- >>".\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,\
- >>".\regfile.reg" ECHO 3f
- >>".\regfile.reg" ECHO "5"=hex:0b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
- >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
- >>".\regfile.reg" ECHO "LangID"=hex:04,08
- >>".\regfile.reg" ECHO "%renchongyi%\\Grisaia.exe"="cs2"
- >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
- >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\DirectInput\MostRecentApplication]
- >>".\regfile.reg" ECHO "Name"="GRISAIA.EXE"
- >>".\regfile.reg" ECHO "Id"="GRISAIA.EXE4D4EA7DF00383000"
- >>".\regfile.reg" ECHO "Version"=hex:0a,05,00,00
- >>".\regfile.reg" ECHO "MostRecentStart"=hex:3a,7c,54,29,48,36,d0,01
- >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
- >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0]
- >>".\regfile.reg" ECHO @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume2\\グリザイアの果実\\Grisaia.exe%b{00000000-0000-0000-0000-000000000000}"
- >>".\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}]
- >>".\regfile.reg" ECHO "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3f,00,00,00,00
- >>".\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,\
- >>".\regfile.reg" ECHO 3f
- >>".\regfile.reg" ECHO "5"=hex:0b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- >>".\regfile.reg" ECHO Windows Registry Editor Version 5.00
- >>".\regfile.reg" ECHO [HKEY_USERS\S-1-5-21-3280445496-1143160547-4056481177-1001_Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
- >>".\regfile.reg" ECHO "LangID"=hex:04,08
- >>".\regfile.reg" ECHO "%renchongyi%\\Grisaia.exe"="cs2"
复制代码
作者: apang 时间: 2015-1-27 19:13
本帖最后由 apang 于 2015-1-27 21:52 编辑
- @echo off & setlocal enabledelayedexpansion
- set "k=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
- for /f "tokens=*" %%i in ('reg query "%k%" /s') do (
- set "s=%%i"
- if /i "!s:~,5!" == "HKEY_" set "SID=%%~nxi"
- if /i "!s:~,16!" == "ProfileImagePath" (
- if /i "%%~nxi" == "%userName%" goto :Next
- )
- )
-
- :Next
- SET "renchongyi=%~dp0"
- SET "renchongyi=%renchongyi:\=\\%"
- (for /f "delims=:" %%i in ('findstr /nb :dynamicScript "%~0"') do (
- for /f "delims=" %%a in ('more +%%i "%~0"') do (
- set "s=%%a"
- set "s=!s:\##=\%SID%!"
- set "s=!s:$$\\=%renchongyi%!"
- echo,!s!
- )
- ))>1.reg
- pause & exit/b
-
- :dynamicScript
- Windows Registry Editor Version 5.00
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FW_Grisaia]
- "DisplayName"="グリザイアの果実"
- "UninstallString"="$$\\uninst.exe"
- [HKEY_USERS\##\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\e6e542c2_0]
- [HKEY_USERS\##\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count]
- "P:\\sebagjvat\\グリザイアの果実\\Tevfnvn.rkr"=hex:03,00,00,00,01,00,00,00,03,00,00,00,\
- 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,\
- 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,\
- C4,73,14,30,D0,01,00,00,00,00
- [HKEY_USERS\##\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\Count]
- "P:\\Hfref\\QZFW\\Qrfxgbc\\グリザイアの果実.yax"=hex:03,00,00,00,01,00,00,00,00,00,00,\
- 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,\
- 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,C5,73,14,30,D0,01,00,00,00,00
- [HKEY_USERS\##\Software\SogouInput.user]
- "CheckFastpassport"=dword:54B694FA
- "LastLoad"=dword:54B5CC18
- "SogouComponentFirstLoad"=dword:54B694BA
- "SogouComponentFirstRun"=dword:54B674D0
- "Used"=dword:54B694BA
- Windows Registry Editor Version 5.00
- [HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
- "LangID"=hex:04,08
- "$$\\Grisaia.exe"="cs2"Windows Registry Editor Version 5.00
- [HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
- "LangID"=hex:04,08
- "$$\\Grisaia.exe"="cs2"
- Windows Registry Editor Version 5.00
- [HKEY_CURRENT_USER\Software\Microsoft\DirectInput\MostRecentApplication]
- "Name"="GRISAIA.EXE"
- "Id"="GRISAIA.EXE4D4EA7DF00383000"
- "Version"=hex:0a,05,00,00
- "MostRecentStart"=hex:3a,7c,54,29,48,36,d0,01
- Windows Registry Editor Version 5.00
- [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0]
- @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume2\\グリザイアの果実\\Grisaia.exe%b{00000000-0000-0000-0000-000000000000}"
- [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0\{219ED5A0-9CBF-4F3A-B927-37C9E5C5F14F}]
- "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3f,00,00,00,00
- "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,\
- 3f
- "5"=hex:0b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- Windows Registry Editor Version 5.00
- [HKEY_USERS\##\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
- "LangID"=hex:04,08
- "$$\\Grisaia.exe"="cs2"
- Windows Registry Editor Version 5.00
- [HKEY_USERS\##\Software\Microsoft\DirectInput\MostRecentApplication]
- "Name"="GRISAIA.EXE"
- "Id"="GRISAIA.EXE4D4EA7DF00383000"
- "Version"=hex:0a,05,00,00
- "MostRecentStart"=hex:3a,7c,54,29,48,36,d0,01
- Windows Registry Editor Version 5.00
- [HKEY_USERS\##\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0]
- @="{0.0.0.00000000}.{cd98d4f9-adca-437a-9e74-9dec67027709}|\\Device\\HarddiskVolume2\\グリザイアの果実\\Grisaia.exe%b{00000000-0000-0000-0000-000000000000}"
- [HKEY_USERS\##\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore\33713289_0\{219ED5A0-9CBF-4F3A-B927-37C9E5C5F14F}]
- "3"=hex:04,00,00,00,00,00,00,00,00,00,80,3f,00,00,00,00
- "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,\
- 3f
- "5"=hex:0b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- Windows Registry Editor Version 5.00
- [HKEY_USERS\##_Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
- "LangID"=hex:04,08
- "$$\\Grisaia.exe"="cs2"
复制代码
作者: 867258173 时间: 2015-1-27 20:39
本帖最后由 867258173 于 2015-1-27 20:40 编辑
回复 6# apang
谢谢,这个刚在笔记本上试了下,SID更改成功了,但有一个问题,这样导出注册表后,%renchongyi%就无效了。导出注册表目的是为了查看是否正确,最终还是要导入注册表。但%renchongyi%代表当前路径的变量无效了,那导入注册表也是无效。希望你能把这代码再改一下,能够在样导出注册表后,不但SID更改,%renchongyi%也能够使用导出当前路径到注册表,最后导入。麻烦您了
作者: apang 时间: 2015-1-27 21:45
回复 7# 867258173
已修改
作者: 867258173 时间: 2015-1-27 22:36
回复 8# apang
谢谢
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |