Board logo

标题: [文本处理] Hope EasyCommand EasyEnCode 批处理加密器 [打印本页]

作者: HOPE2021    时间: 2021-10-10 10:10     标题: Hope EasyCommand EasyEnCode 批处理加密器

本帖最后由 HOPE2021 于 2021-10-10 15:12 编辑

____更新日志______________________________________
    版本 1.0.0000 2021/10/10 本楼
    版本 1.0.0001 2021/10/10 7楼
    版本 1.0.0002 2021/10/10 15楼
    版本 1.0.0003 2021/10/10 16楼
    版本 1.0.0004 2021/10/10 17楼
    版本 1.0.0005 2021/10/10 18楼

____操作手册______________________________________
http://www.bathome.net/redirect.php?goto=findpost&pid=246538&ptid=60317

代码
  1. @Echo Off
  2. Cls
  3. Mode Con: Cols=120
  4. Color 0F
  5. Title Hope(R) Office EasyCommand EasyEnCode
  6. Chcp 936 > Nul
  7. Rem Hope(R) Office EasyCommand EasyEnCode
  8. Echo.
  9. Call :Type "  "
  10. Call :Type "#" 116
  11. Echo.
  12. Call :Type " " 55
  13. Call :Type "EasyEnCode"
  14. Echo.
  15. Call :Type "  "
  16. Call :Type "#" 116
  17. Echo.
  18. Echo.
  19. Echo.  ^>^> Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0000]
  20. Echo.  ^>^> (C) Copyright 2016-2021 Hope Corp.
  21. If "%~1"=="" (
  22. Set FileNum=1
  23. ) Else (
  24. Set FileNum=2
  25. )
  26. Md "%UserProFile%\Desktop" >Nul 2>Nul
  27. Md "%UserProFile%\桌面" >Nul 2>Nul
  28. Set "Pro=%0"
  29. Set "lnk=Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0000]"
  30. Set "Pro=%Pro:"=%"
  31. Mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Hope Office EasyCommand EasyEnCode [Version 1.0.000].lnk""):b.TargetPath=""%Pro%"":b.WorkingDirectory=""%~dp0"":b.Save:close") >Nul 2>Nul
  32. @Goto :Main
  33. :Main
  34. Echo.
  35. Set "FileName=///*无此文件*///"
  36. If "%FileNum%"=="1" (
  37. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:
  38. ) Else (
  39. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:%~1<Nul
  40. Echo.
  41. Set FileName=%~1
  42. Set FileNum=1
  43. )
  44. Set "FileName=%FileName:"=%"
  45. For /F %%I in ('Dir /b') Do (
  46. If "%%I"=="%FileName%" (
  47. Set "FileName=%Cd%\%FileName%"
  48. )
  49. )
  50. Set FileName="%FileName%"
  51. If Not Exist %FileName% (
  52. Echo.
  53. Echo.  ^>^> 无此文件!无法加密...
  54. @Goto :Main
  55. )
  56. For /L %%i in (1,1,2048) Do (
  57. If Not Exist "File-%%i\" (
  58. Md "File-%%i\" >Nul 2>Nul
  59. Set EnCodeDir=File-%%i\
  60. Set Num=%%i
  61. @Goto :EnCode
  62. )
  63. )
  64. Echo.
  65. Echo.  ^>^> 可分配的内存已经占满,无法加密...
  66. @Goto :Main
  67. :EnCode
  68. For /L %%i in (1,1,47) Do Call :RepeatBS
  69. Echo.
  70. Call :Type "  "
  71. Call :Type "+"
  72. Call :Type "=" 4
  73. Call :Type "正在加密"
  74. Call :Type "=" 4
  75. Call :Type "+"
  76. Call :Type "=" 98
  77. Echo.
  78. Echo.
  79. Echo.  文件名: %FileName%
  80. Echo.
  81. Cd %EnCodeDir%
  82. Copy %FileName% "%cd%\File.Bat" > Nul
  83. For /F %%i in ('dir /b File.Bat') do (
  84. For /L %%j in (1,1,%%~zi) do (
  85. Set /P Bytes[FileName]=%Bs%  文件大小: %%j Byte[s]<Nul
  86. )
  87. )
  88. Echo.
  89. Call :VBScript_EnCode
  90. Start /Wait "" "EnCode.VBS"
  91. If Exist "EnCode.VBS" Del "EnCode.VBS"
  92. >> "EnCode.Bat" Echo.
  93. >> "EnCode.Bat" Echo.Cls
  94. Type "File.Bat" >> "EnCode.Bat"
  95. If Exist "File.Bat" Del "File.Bat"
  96. Echo.
  97. Echo.  加密后的文件: "%Cd%\EnCode.Bat"
  98. Echo.
  99. For /F %%i in ('dir /b EnCode.Bat') do (
  100. For /L %%j in (1,1,%%~zi) do (
  101. Set /P Bytes[FileName]=%Bs%  加密后的大小: %%j Byte[s]<Nul
  102. )
  103. )
  104. Echo.
  105. Mshta VBScript:msgbox("加密%FileName:~1,-1%文件成功",64,"Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0000]")(window.close)
  106. Start Explorer "%Cd%"
  107. Start "" "Notepad" "EnCode.Bat"
  108. Cd..
  109. Echo.
  110. Call :Type "  "
  111. Call :Type "+"
  112. Call :Type "=" 4
  113. Call :Type "=" 8
  114. Call :Type "=" 4
  115. Call :Type "+"
  116. Call :Type "=" 98
  117. Echo.
  118. @Goto :Main
  119. :RepeatBS
  120. Set "Bs=%Bs%"
  121. @Goto :Eof
  122. :Type <Text> [Num]
  123. %=Company {Hope Studio}=%
  124. %=Author  {Hope Studio}=%
  125. If '%2'=='' (
  126. Set /p Text=#%~1<Nul
  127. @Goto :Eof
  128. )
  129. If Not '%2'=='' (
  130. For /l %%I in (1,1,%2) Do (
  131. Set /p Text=#%~1<Nul
  132. )
  133. )
  134. @Goto :Eof
  135. :VBScript_EnCode
  136. > EnCode.VBS Echo.Function WriteTextFile(strPath, text)
  137. >> EnCode.VBS Echo.With CreateObject("ADODB.Stream")
  138. >> EnCode.VBS Echo..Open
  139. >> EnCode.VBS Echo..type = 2
  140. >> EnCode.VBS Echo..WriteText text
  141. >> EnCode.VBS Echo..SaveToFile strPath
  142. >> EnCode.VBS Echo..close()
  143. >> EnCode.VBS Echo.End With
  144. >> EnCode.VBS Echo.End Function
  145. >> EnCode.VBS Echo.
  146. >> EnCode.VBS Echo.Dim EnCode
  147. >> EnCode.VBS Echo.EnCode=WriteTextFile("EnCode.Bat","")
  148. @Goto :Eof
复制代码
By Hope2021
谢谢.
作者: HOPE2021    时间: 2021-10-10 10:13

本帖最后由 HOPE2021 于 2021-10-10 10:47 编辑

回复 1# HOPE2021
Hope(R) Office EasyCommand EasyEnCode 操作使用指南

___目录_________________________________________________

1. 那些文件不适合加密?

        #1. 调用PowerShell

        #2. 内嵌脚本,内嵌脚本无法加密

        #3. 用For来处理自身文件的文本[并输出]

        #4. 已经加密的文件

2. 加密方法

___正文_________________________________________________

1. 那些文件不适合加密?

        #1. 调用PowerShell

        例子:
  1. #&cls&@powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" & exit
  2. cls
  3. #------------------------初始化区------------------------------------
  4. [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") #加载WinForm库
  5. [void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
  6. $url = 'http://dict-co.iciba.com/api/dictionary.php?type=json&key=C6AAC87C99A4223504F6B7A79C628120&w={0}'
  7. #Windows API
  8. $code=@"
  9.     using System;
  10.     using System.Runtime.InteropServices;
  11.     public static class GetApi{
  12.         [DllImport("user32.dll")]
  13.         public static extern bool SetWindowPos(IntPtr hWnd,IntPtr hWnd0,uint x,uint y,uint cx,uint cy,uint flag); //声明 Windows API 函数
  14.         [DllImport("user32.dll")]
  15.         private static extern bool ShowWindow(IntPtr hWnd,uint showType); //声明 Windows API 函数
  16.         [DllImport("kernel32.dll")]
  17.         private static extern IntPtr GetConsoleWindow(); //声明 Windows API 函数
  18. public static bool ShowConsoleWindow(uint showType){
  19. return ShowWindow(GetConsoleWindow(),showType);
  20. }
  21.     }
  22. "@
  23. Add-Type -TypeDefinition $code
  24. #隐藏控制台窗口
  25. [void][GetApi]::ShowConsoleWindow(0)
  26. #------------------------界面区-------------------------------------
  27. #0.设置主窗口尺寸
  28. $mainFormWidth = 400                 #主窗口宽度
  29. $mainFormHeight = 300                #主窗口高度
  30. #1.创建主窗口
  31. $form_main = New-Object "System.Windows.Forms.Form"
  32. $form_main.Width = $mainFormWidth                                                   #设置主窗口宽度
  33. $form_main.Height = $mainFormHeight                                                 #设置主窗口高度
  34. $form_main.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen   #主窗口居中屏幕
  35. $form_main.Text = "在线英汉词典"                                                    #主窗口标题
  36. #主窗口置顶
  37. [GetApi]::SetWindowPos($form_main.Handle,-1,$form_main.Location.X,$form_main.Location.Y,$form_main.Width,$form_main.Height,64)
  38. #2.创建输入框
  39. $tb_input = New-Object 'System.Windows.Forms.TextBox'
  40. $tb_input.Height = $form_main.Height / 5
  41. $tb_input.Width = $form_main.Width
  42. $tb_input.BackColor = '#012456'
  43. $tb_input.ForeColor = 'yellow'
  44. $form_main.Controls.Add($tb_input)
  45. #创建显示框
  46. $rtb_show = New-Object 'System.Windows.Forms.RichTextBox'
  47. $rtb_show.Height = $form_main.Height - $tb_input.Height
  48. $rtb_show.Width = $form_main.Width
  49. $rtb_show.Location = New-Object 'System.Drawing.Point' 0,$tb_input.Height
  50. $rtb_show.BackColor = '#012456'
  51. $rtb_show.ForeColor = '#F5F5F5'
  52. $rtb_show.ReadOnly = $true
  53. $form_main.Controls.Add($rtb_show)
  54. #自定义方法
  55. function Print-Host($obj){ Write-Host ($obj | Out-String) }
  56. $js = New-Object 'System.Web.Script.Serialization.JavaScriptSerializer'
  57. $whr = New-Object -ComObject 'WinHttp.WinHttpRequest.5.1'
  58. #------------------------事件区-------------------------------------
  59. $tb_input.add_TextChanged({
  60.     cls
  61.     $whr.Open('GET',($url -f $tb_input.Text),$false)
  62.     $errMsg = '';
  63.     try{$whr.Send()}catch{$errMsg = $_.Exception.Message}
  64.     if($whr.Status -ne 200){
  65.         [System.Windows.Forms.MessageBox]::Show(('错误代码:{0} {1} {2}' -f $whr.Status,$whr.StatusText,$errMsg),'网络连接失败')
  66.         return
  67.     }
  68.     $str = [System.Text.RegularExpressions.Regex]::Unescape($whr.ResponseText);
  69.     $means = [System.Text.RegularExpressions.Regex]::Matches($str,'"means":\[".*?"\]}')
  70.     if($means.Count -eq 0){ $means = [regex]::Matches($str,'"word_mean":".*?"') }
  71.     $str = ''
  72.     for($i = 0;$i -lt $means.Count;$i++){
  73.         $str += '' + ($i + 1) + ":"
  74.         $parts = ($means[$i].Value -replace '^.*:\["|"\]}$|word_mean|:','' -replace ',',',') -split '","'
  75.         for($j = 0;$j -lt $parts.Count;$j++){ $str += "`t" + ($parts[$j] -replace '"','') + "`r`n" }
  76.         $str += "`r`n"
  77.     }
  78.     Print-Host $str
  79.     $rtb_show.Text = $str
  80. })
  81. $form_main.add_SizeChanged({
  82.     $tb_input.Width = $form_main.Width
  83.     $rtb_show.Height = $form_main.Height - $tb_input.Height
  84.     $rtb_show.Width = $form_main.Width
  85. })
  86. $form_main.add_Load({$tb_input.Focus()})
  87. #------------------------结  束-------------------------------------
  88. #4.显示主窗口
  89. $form_main.ShowDialog()
复制代码

作者: HOPE2021    时间: 2021-10-10 10:15

回复 2# HOPE2021
        #2. 内嵌脚本,内嵌脚本无法加密

        例子:
  1. @echo off
  2. Rem 来自https://www.dostips.com/forum/viewtopic.php?f=3&t=9848&p=63348
  3. Rem 作者Lauri
  4. chcp 936 > nul
  5. title 劳里的幻想世界
  6. color 03
  7. @goto INSTALL_COLOR
  8. :INSTALL_COLOR
  9. echo.
  10. echo.正在加载图形引擎...
  11. (
  12. echo.@echo off
  13. echo.chcp 936 ^> nul
  14. echo.Setlocal EnableDelayedExpansion
  15. echo.REM setlocal enableextensions
  16. echo.set dstdir=c:\tmpColorDirtoDelete
  17. echo.IF EXIST %%dstdir%% goto errExist
  18. echo.@mkdir %%dstdir%%
  19. echo.@cd %%dstdir%%
  20. echo.set count=0
  21. echo.REM DEFINISCO IL CARATTERE BACKSPACE!
  22. echo.set "$Defines=$BS"    & set "$Details=Create $ESC Ascii-0x1B-27, Expansion insensitive"
  23. echo.   for /f "delims=#" %%%%a in ^(
  24. echo.      '"prompt #$H# &echo on &for %%%%b in (1) do rem"'
  25. echo.   ^) do ^(
  26. echo.      set "%%$Defines%%=%%%%a"
  27. echo.      set "%%$Defines%%=!$BS:~0,1!"
  28. echo.   ^)
  29. echo.FOR %%%%a IN ^(%%*^) DO ^(
  30. echo. FOR /F "usebackq delims=# tokens=1,*" %%%%b IN ^('%%%%a'^) DO ^(
  31. echo.    REM echo %%%%b sara' di colore %%%%c
  32. echo.    set /A count=!count!+1
  33. echo.    set nomefile=%%%%b
  34. echo.    IF %%%%c.==. ^(
  35. echo.        set colore=03
  36. echo.    ^) ELSE ^(
  37. echo.    set colore=%%%%c
  38. echo.    ^)
  39. echo.    REM SET /P ".=" %%%%b
  40. echo.    SET /P ".=%%$BS%% " ^<nul ^>%%%%b
  41. echo.    REM echo !count!^>%%%%b
  42. echo.    REM echo FINDSTR /A:%%%%c /C:"!count!" /S "%%%%b"
  43. echo.    REM more %%%%b
  44. echo.    set bin=%%%%b
  45. echo. ^)
  46. echo. REM FINE INNER FOR
  47. echo.    REM echo FINDSTR /A:!colore! /C:"!count!" /S "!nomefile!"
  48. echo.    FINDSTR /A:!colore! /C:" " /S "!nomefile!"
  49. echo.    REM goto end
  50. echo.^)
  51. echo.REM FINE OUTER FOR
  52. echo.echo.
  53. echo.REM ERROR HANDLING
  54. echo.goto chiusura
  55. echo.:errExist
  56. echo.echo 临时目录%%dstdir%%已存在.在继续或更改批处理中的路径之前将其删除.
  57. echo.goto pulizia
  58. echo.:chiusura
  59. echo.:pulizia
  60. echo.cd..
  61. echo.rd /S /Q %%dstdir%%
  62. echo.goto end
  63. echo.:end
  64. ) > color.bat
  65. SetLocal EnableDelayedExpansion
复制代码

作者: HOPE2021    时间: 2021-10-10 10:24

回复 3# HOPE2021
        #3. 用For来处理自身文件的文本[并输出]

        例子:
  1. @Echo Off
  2. Cd.>"%0.Bat"
  3. For /F "skip=6 delims=" %%i in ('Type %0') Do Echo.%%i >> "%0.Bat"
  4. Start "" "%0.Bat"
  5. Pause > Nul
  6. @Echo Off
  7. Echo.Hello,World!
  8. Pause > Nul
复制代码

作者: HOPE2021    时间: 2021-10-10 10:27

回复 4# HOPE2021
        #4. 已经加密的文件

        例子:
  1. ਍汃൳䀊捅潨传晦਍摃㸮┢⸰慂≴਍潆⁲䘯∠歳灩㘽搠汥浩㵳•┥⁩湩⠠吧灹⁥〥⤧䐠捅潨┮椥㸠 ̄┢⸰慂≴਍瑓牡⁴∢∠〥䈮瑡ഢ倊畡敳㸠丠汵਍਍䕀档晏൦䔊档⹯效汬Ɐ潗汲Ⅴ਍慐獵⁥ ̄畎
复制代码

作者: HOPE2021    时间: 2021-10-10 10:40

回复 5# HOPE2021
2. 加密方法

        #1. 打开程序,将需要加密的文件拖入窗体

        #2. 将需要加密的文件拖入到程序图标中

        #3. 将程序另存为 EasyEnCode.Bat 或 EasyEnCode.Cmd ,在命令行输入: EasyEnCode "文件名"
作者: HOPE2021    时间: 2021-10-10 11:24

回复 1# HOPE2021
版本 1.0.0001
  1. @Echo Off
  2. Cls
  3. Mode Con: Cols=120 Lines=2001
  4. Color 0F
  5. Title Hope(R) Office EasyCommand EasyEnCode
  6. Chcp 936 > Nul
  7. Rem Hope(R) Office EasyCommand EasyEnCode
  8. Echo.
  9. Call :Type "  "
  10. Call :Type "#" 116
  11. Echo.
  12. Call :Type " " 55
  13. Call :Type "EasyEnCode"
  14. Echo.
  15. Call :Type "  "
  16. Call :Type "#" 116
  17. Echo.
  18. Echo.
  19. Echo.  ^>^> Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0001]
  20. Echo.  ^>^> (C) Copyright 2016-2021 Hope Corp.
  21. If "%~1"=="" (
  22. Set FileNum=1
  23. ) Else (
  24. Set FileNum=2
  25. )
  26. Md "%UserProFile%\Desktop" >Nul 2>Nul
  27. Md "%UserProFile%\桌面" >Nul 2>Nul
  28. Set "Pro=%0"
  29. Set "lnk=Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0001]"
  30. Set "Pro=%Pro:"=%"
  31. Mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Hope Office EasyCommand EasyEnCode [Version 1.0.0001].lnk""):b.TargetPath=""%Pro%"":b.WorkingDirectory=""%~dp0"":b.Save:close") >Nul 2>Nul
  32. @Goto :Main
  33. :Main
  34. Echo.
  35. Set "FileName=///*无此文件*///"
  36. If "%FileNum%"=="1" (
  37. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:
  38. ) Else (
  39. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:%~1<Nul
  40. Echo.
  41. Set FileName=%~1
  42. Set FileNum=1
  43. )
  44. Set "FileName=%FileName:"=%"
  45. For /F %%I in ('Dir /b') Do (
  46. If "%%I"=="%FileName%" (
  47. Set "FileName=%Cd%\%FileName%"
  48. )
  49. )
  50. Set FileName="%FileName%"
  51. If Not Exist %FileName% (
  52. Echo.
  53. Echo.  ^>^> 无此文件!无法加密...
  54. @Goto :Main
  55. )
  56. Set FilenameExtension=%FileName:~-5%
  57. Set FilenameExtension=%FilenameExtension:~0,4%
  58. For /L %%i in (1,1,2048) Do (
  59. If Not Exist "File-%%i\" (
  60. Md "File-%%i\" >Nul 2>Nul
  61. Set EnCodeDir=File-%%i\
  62. Set Num=%%i
  63. @Goto :EnCode
  64. )
  65. )
  66. Echo.
  67. Echo.  ^>^> 可分配的内存已经占满,无法加密...
  68. @Goto :Main
  69. :EnCode
  70. Set "Choice="
  71. If /I Not "%FilenameExtension%"==".Bat" (
  72. If /I Not "%FilenameExtension%"==".Cmd" (
  73. @Goto :Choice
  74. )
  75. )
  76. For /L %%i in (1,1,47) Do Call :RepeatBS
  77. Echo.
  78. Call :Type "  "
  79. Call :Type "+"
  80. Call :Type "=" 4
  81. Call :Type "正在加密"
  82. Call :Type "=" 4
  83. Call :Type "+"
  84. Call :Type "=" 98
  85. Echo.
  86. Echo.
  87. Echo.  文件名: %FileName%
  88. Echo.
  89. Cd %EnCodeDir%
  90. Copy %FileName% "%cd%\File.Bat" > Nul
  91. For /F %%i in ('dir /b File.Bat') do (
  92. For /L %%j in (1,1,%%~zi) do (
  93. Set /P Bytes[FileName]=%Bs%  文件大小: %%j Byte[s]<Nul
  94. )
  95. )
  96. Echo.
  97. Call :VBScript_EnCode
  98. Start /Wait "" "EnCode.VBS"
  99. If Exist "EnCode.VBS" Del "EnCode.VBS"
  100. >> "EnCode.Bat" Echo.
  101. >> "EnCode.Bat" Echo.Cls
  102. Type "File.Bat" >> "EnCode.Bat"
  103. If Exist "File.Bat" Del "File.Bat"
  104. Echo.
  105. Echo.  加密后的文件: "%Cd%\EnCode.Bat"
  106. Echo.
  107. For /F %%i in ('dir /b EnCode.Bat') do (
  108. For /L %%j in (1,1,%%~zi) do (
  109. Set /P Bytes[FileName]=%Bs%  加密后的大小: %%j Byte[s]<Nul
  110. )
  111. )
  112. Echo.
  113. Mshta VBScript:msgbox("加密%FileName:~1,-1%文件成功",64,"Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0001]")(window.close)
  114. Start Explorer "%Cd%"
  115. Start "" "Notepad" "EnCode.Bat"
  116. Cd..
  117. Echo.
  118. Call :Type "  "
  119. Call :Type "+"
  120. Call :Type "=" 4
  121. Call :Type "=" 8
  122. Call :Type "=" 4
  123. Call :Type "+"
  124. Call :Type "=" 98
  125. Echo.
  126. @Goto :Main
  127. :RepeatBS
  128. Set "Bs=%Bs%"
  129. @Goto :Eof
  130. :Type <Text> [Num]
  131. %=Company {Hope Studio}=%
  132. %=Author  {Hope Studio}=%
  133. If '%2'=='' (
  134. Set /p Text=#%~1<Nul
  135. @Goto :Eof
  136. )
  137. If Not '%2'=='' (
  138. For /l %%I in (1,1,%2) Do (
  139. Set /p Text=#%~1<Nul
  140. )
  141. )
  142. @Goto :Eof
  143. :VBScript_EnCode
  144. > EnCode.VBS Echo.Function WriteTextFile(strPath, text)
  145. >> EnCode.VBS Echo.With CreateObject("ADODB.Stream")
  146. >> EnCode.VBS Echo..Open
  147. >> EnCode.VBS Echo..type = 2
  148. >> EnCode.VBS Echo..WriteText text
  149. >> EnCode.VBS Echo..SaveToFile strPath
  150. >> EnCode.VBS Echo..close()
  151. >> EnCode.VBS Echo.End With
  152. >> EnCode.VBS Echo.End Function
  153. >> EnCode.VBS Echo.
  154. >> EnCode.VBS Echo.Dim EnCode
  155. >> EnCode.VBS Echo.EnCode=WriteTextFile("EnCode.Bat","")
  156. @Goto :Eof
  157. :Choice
  158. Echo.
  159. Echo.  ^>^> 此文件不是批处理文件,是否要加密?[Y/N][输入完毕后请按下回车]
  160. Echo.
  161. Set /p "Choice=#  ^>^> "
  162. If /I Not "%Choice%"=="Y" (
  163. @Goto :Main
  164. )
  165. Set "FilenameExtension=.Bat"
  166. @Goto :EnCode
复制代码

作者: cmd1152    时间: 2021-10-10 12:11

合作
作者: cmd1152    时间: 2021-10-10 12:19

好家伙,自动创建快捷方式
作者: HOPE2021    时间: 2021-10-10 12:21

回复 9# cmd1152
当然,所以不支持Win2000或更早版本
作者: cmd1152    时间: 2021-10-10 12:55

回复 10# HOPE2021


    调试器功能安装中,请不要进行更新......
作者: cmd1152    时间: 2021-10-10 13:09     标题: Debug安装完成

本帖最后由 cmd1152 于 2021-10-10 13:26 编辑

Version 1.0.0002
打开Debug时for显示的Backspce字符被禁用,是因为不禁用会吃掉]

   本代码存在已经被解决的BUG,请去此楼获得代码

作者: cmd1152    时间: 2021-10-10 13:11

抱歉,刚刚的DeBug出现了一个小问题,请稍后...
作者: cmd1152    时间: 2021-10-10 13:15

正在优化代码并增加详细的Debug
作者: cmd1152    时间: 2021-10-10 13:22

本帖最后由 cmd1152 于 2021-10-10 13:28 编辑

Version 1.0.0002
代码优化完成
Debug安装完成
  1. @set DeBug=1 %   0代表关闭DeBug,1代表打开DeBug   %
  2. @%Cmd1152提供代码优化和Debug%
  3. @Echo Off
  4. Cls
  5. call :msg "设置窗口大小"
  6. Mode Con: Cols=120 Lines=6550
  7. call :msg "设置颜色"
  8. Color 0F
  9. call :msg "设置标题"
  10. Title Hope(R) Office EasyCommand EasyEnCode
  11. call :msg "设置编码"
  12. Chcp 936 > Nul
  13. Rem Hope(R) Office EasyCommand EasyEnCode
  14. Echo.
  15. call :msg "绘图"
  16. Call :Type "  "
  17. Call :Type "#" 116
  18. Echo.
  19. Call :Type " " 55
  20. Call :Type "EasyEnCode"
  21. Echo.
  22. Call :Type "  "
  23. Call :Type "#" 116
  24. Echo.
  25. call :msg "版权声明"
  26. Echo.
  27. Echo.  ^>^> Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0002]
  28. Echo.  ^>^> (C) Copyright 2016-2021 Hope ^& Cms1152 Corp.
  29. If "%~1"=="" (
  30. Set FileNum=1
  31. call :msg "没有调用参数"
  32. ) Else (
  33. Set FileNum=2
  34. call :msg "有参数"
  35. )
  36. call :msg "创建文件夹"
  37. Md "%UserProFile%\Desktop" >Nul 2>Nul
  38. Md "%UserProFile%\桌面" >Nul 2>Nul
  39.     call :msg "set"
  40. Set "Pro=%0"
  41. Set "lnk=Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0001]"
  42. Set "Pro=%Pro:"=%"
  43. call :msg "创建快捷方式"
  44. Mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Hope Office EasyCommand EasyEnCode [Version 1.0.0001].lnk""):b.TargetPath=""%Pro%"":b.WorkingDirectory=""%~dp0"":b.Save:close") >Nul 2>Nul
  45. @Goto :Main
  46. :Main
  47. Echo.
  48. Set "FileName=///*无此文件*///"
  49. If "%FileNum%"=="1" (
  50. call :msg "输入"
  51. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:
  52. ) Else (
  53.     call :msg "参数显示"
  54. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:%~1<Nul
  55. Echo.
  56. Set FileName=%~1
  57. Set FileNum=1
  58. )
  59.     call :msg "set"
  60. Set "FileName=%FileName:"=%"
  61. For /F %%I in ('Dir /b') Do (
  62. If "%%I"=="%FileName%" (
  63. Set "FileName=%Cd%\%FileName%"
  64. )
  65. )
  66. Set FileName="%FileName%"
  67. If Not Exist %FileName% (
  68. call :msg "返回:加密错误:找不到文件"
  69. Echo.
  70. Echo.  ^>^> 无此文件!无法加密...
  71. @Goto :Main
  72. )
  73. Set FilenameExtension=%FileName:~-5%
  74. Set FilenameExtension=%FilenameExtension:~0,4%
  75. For /L %%i in (1,1,2048) Do (
  76. If Not Exist "File-%%i\" (
  77. Md "File-%%i\" >Nul 2>Nul
  78. Set EnCodeDir=File-%%i\
  79. Set Num=%%i
  80. @Goto :EnCode
  81. )
  82. )
  83.     call :msg "加密失败:内存错误:文件夹超过2048"
  84. Echo.
  85. Echo.  ^>^> 可分配的内存已经占满,无法加密...
  86. @Goto :Main
  87. :EnCode
  88. Set "Choice="
  89. call :msg "文件判断"
  90. If /I Not "%FilenameExtension%"==".Bat" (
  91. call :msg "不是bat文件"
  92. If /I Not "%FilenameExtension%"==".Cmd" (
  93. call :msg "不是批处理文件"
  94. @Goto :Choice
  95. )
  96. )
  97.     call :msg "for 17"
  98. For /L %%i in (1,1,47) Do Call :RepeatBS
  99. Echo.
  100. call :msg "绘图"
  101. Call :Type "  "
  102. Call :Type "+"
  103. Call :Type "=" 4
  104. Call :Type "正在加密"
  105. Call :Type "=" 4
  106. Call :Type "+"
  107. Call :Type "=" 98
  108. Echo.
  109. Echo.
  110. Echo.  文件名: %FileName%
  111. Echo.
  112.     call :msg "正在加密..."
  113. Cd %EnCodeDir%
  114. Copy %FileName% "%cd%\File.Bat" > Nul
  115. For /F %%i in ('dir /b File.Bat') do (
  116. For /L %%j in (1,1,%%~zi) do (
  117.     call :msg for返回%%j,最后会返回%%~zi<nul
  118. Set /P Bytes[FileName]=%Bs%  文件大小: %%j Byte[s] <Nul
  119. )
  120. )
  121. Echo.
  122. Call :VBScript_EnCode
  123.     call :msg "打开EnCode.vbs,等待他结束"
  124. Start /W "" "EnCode.VBS"
  125.     Del /f "EnCode.VBS" 2>nul
  126. >> "EnCode.Bat" Echo.
  127. >> "EnCode.Bat" Echo.Cls
  128. Type "File.Bat" >> "EnCode.Bat"
  129. Del /f "File.Bat" 2>nul
  130.     call :msg "完成"
  131. Echo.
  132. Echo.  加密后的文件: "%Cd%\EnCode.Bat"
  133. Echo.
  134. For /F %%i in ('dir /b EnCode.Bat') do (
  135. For /L %%j in (1,1,%%~zi) do (
  136.     call :msg for返回%%j,最后会返回%%~zi<nul
  137. Set /P Bytes[FileName]=%Bs%  加密后的大小: %%j Byte[s] <Nul
  138. )
  139. )
  140. Echo.
  141.     call :msg "Msg"
  142. Mshta VBScript:msgbox("加密%FileName:~1,-1%文件成功",64,"Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0001]")(window.close)
  143.     call :msg "用资源管理器打开文件夹"
  144. Start Explorer "%Cd%"
  145.     call :msg "用记事本打开程序"
  146. Start "" "Notepad" "EnCode.Bat"
  147. Cd..
  148.     call :msg "绘图"
  149. Echo.
  150. Call :Type "  "
  151. Call :Type "+"
  152. Call :Type "=" 4
  153. Call :Type "=" 8
  154. Call :Type "=" 4
  155. Call :Type "+"
  156. Call :Type "=" 98
  157. Echo.
  158. @Goto :Main
  159. :RepeatBS
  160.     call :msg "Set Bs"
  161. Set "Bs=%Bs%"
  162. @Goto :Eof
  163. :Type <Text> [Num]
  164. call :msg "循环字体"
  165. %=Company {Hope Studio}=%
  166. %=Author  {Hope Studio}=%
  167. If '%2'=='' (
  168. Set /p Text=#%~1<Nul
  169. @Goto :Eof
  170. )
  171. If Not '%2'=='' (
  172. For /l %%I in (1,1,%2) Do (
  173. Set /p Text=#%~1<Nul
  174. )
  175. )
  176. @Goto :Eof
  177. :VBScript_EnCode
  178.     call :msg "写入文件EnCode.vbs"
  179. > EnCode.VBS Echo.Function WriteTextFile(strPath, text)
  180. >> EnCode.VBS Echo.With CreateObject("ADODB.Stream")
  181. >> EnCode.VBS Echo..Open
  182. >> EnCode.VBS Echo..type = 2
  183. >> EnCode.VBS Echo..WriteText text
  184. >> EnCode.VBS Echo..SaveToFile strPath
  185. >> EnCode.VBS Echo..close()
  186. >> EnCode.VBS Echo.End With
  187. >> EnCode.VBS Echo.End Function
  188. >> EnCode.VBS Echo.
  189. >> EnCode.VBS Echo.Dim EnCode
  190. >> EnCode.VBS Echo.EnCode=WriteTextFile("EnCode.Bat","")
  191. call :msg "写入文件EnCode.vbs完成"
  192. @Goto :Eof
  193. :Choice
  194.     call :msg "[信息]"
  195. Echo.
  196. Echo.  ^>^> 此文件不是批处理文件,是否要加密?[Y/N][输入完毕后请按下回车]
  197. Echo.
  198. Set /p "Choice=#  >> "
  199. If /I Not "%Choice%"=="Y" (
  200. call :msg "继续"
  201. @Goto :Main
  202. )
  203. call :msg "变量FilenameExtension=.Bat"
  204. Set "FilenameExtension=.Bat"
  205. @Goto :EnCode
  206. :Msg
  207.     if %debug%==1 (
  208.     set /P=                                                            调试:%~1<nul
  209.     echo;
  210.     )
  211. goto :eof
复制代码

作者: cmd1152    时间: 2021-10-10 13:35

本帖最后由 cmd1152 于 2021-10-10 13:52 编辑

1.0.0003
修复窗口太小
优化快捷方式和Debug
  1. @set "DeBug=1" %   0代表关闭DeBug,1代表打开DeBug   %
  2. @%Cmd1152提供代码优化和Debug%
  3. @Echo Off
  4.         set Version=1.0.0003
  5. Cls
  6. call :msg "设置窗口大小"
  7. Mode Con: Cols=120 Lines=68800
  8. call :msg "设置颜色"
  9. Color 0F
  10. call :msg "设置标题"
  11. Title Hope(R) Office EasyCommand EasyEnCode
  12. call :msg "设置编码"
  13. Chcp 936 > Nul
  14. Rem Hope(R) Office EasyCommand EasyEnCode
  15. Echo.
  16. call :msg "绘图"
  17. Call :Type "  "
  18. Call :Type "#" 116
  19. Echo.
  20. Call :Type " " 55
  21. Call :Type "EasyEnCode"
  22. Echo.
  23. Call :Type "  "
  24. Call :Type "#" 116
  25. Echo.
  26. call :msg "版权声明"
  27. Echo.
  28. Echo.  ^>^> Hope(R) Office EasyCommand EasyEnCode [Version %Version%]
  29. Echo.  ^>^> (C) Copyright 2016-2021 Hope ^& Cms1152 Corp.
  30. If "%~1"=="" (
  31. Set FileNum=1
  32. call :msg "没有调用参数"
  33. ) Else (
  34. Set FileNum=2
  35. call :msg "有参数"
  36. )
  37. call :msg "创建文件夹"
  38. Md "%UserProFile%\Desktop" >Nul 2>Nul
  39. Md "%UserProFile%\桌面" >Nul 2>Nul
  40.     call :msg "set"
  41. Set "Pro=%0"
  42. Set "lnk=Hope(R) Office EasyCommand EasyEnCode [Version %Version%]"
  43. Set "Pro=%Pro:"=%"
  44. call :msg "创建快捷方式"
  45. Mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Hope Office EasyCommand EasyEnCode [Version %Version%].lnk""):b.TargetPath=""%Pro%"":b.WorkingDirectory=""%~dp0"":b.Save:close") >Nul 2>Nul
  46. @Goto :Main
  47. :Main
  48. Echo.
  49. Set "FileName=///*无此文件*///"
  50. If "%FileNum%"=="1" (
  51. call :msg "输入"
  52. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:
  53. ) Else (
  54.     call :msg "参数显示"
  55. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:%~1<Nul
  56. Echo.
  57. Set FileName=%~1
  58. Set FileNum=1
  59. )
  60.     call :msg "set"
  61. Set "FileName=%FileName:"=%"
  62. For /F %%I in ('Dir /b') Do (
  63. If "%%I"=="%FileName%" (
  64. Set "FileName=%Cd%\%FileName%"
  65. )
  66. )
  67. Set FileName="%FileName%"
  68. If Not Exist %FileName% (
  69. call :msg "返回:加密错误:找不到文件"
  70. Echo.
  71. Echo.  ^>^> 无此文件!无法加密...
  72. @Goto :Main
  73. )
  74. Set FilenameExtension=%FileName:~-5%
  75. Set FilenameExtension=%FilenameExtension:~0,4%
  76. For /L %%i in (1,1,2048) Do (
  77. If Not Exist "File-%%i\" (
  78. Md "File-%%i\" >Nul 2>Nul
  79. Set EnCodeDir=File-%%i\
  80. Set Num=%%i
  81. @Goto :EnCode
  82. )
  83. )
  84.     call :msg "加密失败:内存错误:文件夹超过2048"
  85. Echo.
  86. Echo.  ^>^> 可分配的内存已经占满,无法加密...
  87. @Goto :Main
  88. :EnCode
  89. Set "Choice="
  90. call :msg "文件判断"
  91. If /I Not "%FilenameExtension%"==".Bat" (
  92. call :msg "不是bat文件"
  93. If /I Not "%FilenameExtension%"==".Cmd" (
  94. call :msg "不是批处理文件"
  95. @Goto :Choice
  96. )
  97. )
  98.     call :msg "for 17"
  99. For /L %%i in (1,1,47) Do Call :RepeatBS
  100. Echo.
  101. call :msg "绘图"
  102. Call :Type "  "
  103. Call :Type "+"
  104. Call :Type "=" 4
  105. Call :Type "正在加密"
  106. Call :Type "=" 4
  107. Call :Type "+"
  108. Call :Type "=" 98
  109. Echo.
  110. Echo.
  111. Echo.  文件名: %FileName%
  112. Echo.
  113.     call :msg "正在加密..."
  114. Cd %EnCodeDir%
  115. Copy %FileName% "%cd%\File.Bat" > Nul
  116. For /F %%i in ('dir /b File.Bat') do (
  117. For /L %%j in (1,1,%%~zi) do (
  118.     call :msg for返回%%j,最后会返回%%~zi<nul
  119. Set /P Bytes[FileName]=%Bs%  文件大小: %%j Byte[s] <Nul
  120. )
  121. )
  122. Echo.
  123. Call :VBScript_EnCode
  124.     call :msg "打开EnCode.vbs,等待他结束"
  125. Start /W "" "EnCode.VBS"
  126.     Del /f "EnCode.VBS" 2>nul
  127. >> "EnCode.Bat" Echo.
  128. >> "EnCode.Bat" Echo.Cls
  129. Type "File.Bat" >> "EnCode.Bat"
  130. Del /f "File.Bat" 2>nul
  131.     call :msg "完成"
  132. Echo.
  133. Echo.  加密后的文件: "%Cd%\EnCode.Bat"
  134. Echo.
  135. For /F %%i in ('dir /b EnCode.Bat') do (
  136. For /L %%j in (1,1,%%~zi) do (
  137.     call :msg for返回%%j,最后会返回%%~zi<nul
  138. Set /P Bytes[FileName]=%Bs%  加密后的大小: %%j Byte[s] <Nul
  139. )
  140. )
  141. Echo.
  142.     call :msg "Msg"
  143. Mshta VBScript:msgbox("加密%FileName:~1,-1%文件成功",64,"Hope(R) Office EasyCommand EasyEnCode [Version %Version%]")(window.close)
  144.     call :msg "用资源管理器打开文件夹"
  145. Start Explorer "%Cd%"
  146.     call :msg "用记事本打开程序"
  147. Start "" "Notepad" "EnCode.Bat"
  148. Cd..
  149.     call :msg "绘图"
  150. Echo.
  151. Call :Type "  "
  152. Call :Type "+"
  153. Call :Type "=" 4
  154. Call :Type "=" 8
  155. Call :Type "=" 4
  156. Call :Type "+"
  157. Call :Type "=" 98
  158. Echo.
  159. @Goto :Main
  160. :RepeatBS
  161.     call :msg "Set Bs"
  162. Set "Bs=%Bs%"
  163. @Goto :Eof
  164. :Type <Text> [Num]
  165. call :msg "循环字体"
  166. %=Company {Hope Studio}=%
  167. %=Author  {Hope Studio}=%
  168. If '%2'=='' (
  169. Set /p Text=#%~1<Nul
  170. @Goto :Eof
  171. )
  172. If Not '%2'=='' (
  173. For /l %%I in (1,1,%2) Do (
  174. Set /p Text=#%~1<Nul
  175. )
  176. )
  177. @Goto :Eof
  178. :VBScript_EnCode
  179.     call :msg "写入文件EnCode.vbs"
  180. > EnCode.VBS Echo.Function WriteTextFile(strPath, text)
  181. >> EnCode.VBS Echo.With CreateObject("ADODB.Stream")
  182. >> EnCode.VBS Echo..Open
  183. >> EnCode.VBS Echo..type = 2
  184. >> EnCode.VBS Echo..WriteText text
  185. >> EnCode.VBS Echo..SaveToFile strPath
  186. >> EnCode.VBS Echo..close()
  187. >> EnCode.VBS Echo.End With
  188. >> EnCode.VBS Echo.End Function
  189. >> EnCode.VBS Echo.
  190. >> EnCode.VBS Echo.Dim EnCode
  191. >> EnCode.VBS Echo.EnCode=WriteTextFile("EnCode.Bat","")
  192. call :msg "写入文件EnCode.vbs完成"
  193. @Goto :Eof
  194. :Choice
  195.     call :msg "[信息]"
  196. Echo.
  197. Echo.  ^>^> 此文件不是批处理文件,是否要加密?[Y/N][输入完毕后请按下回车]
  198. Echo.
  199. Set /p "Choice=#  >> "
  200. If /I Not "%Choice%"=="Y" (
  201. call :msg "继续"
  202. @Goto :Main
  203. )
  204. call :msg "变量FilenameExtension=.Bat"
  205. Set "FilenameExtension=.Bat"
  206. @Goto :EnCode
  207. :Msg
  208.     if %debug%==1 (
  209.     set /P=                                                     调试:%~1<nul
  210.     echo;
  211.     )
  212. goto :eof
复制代码

作者: HOPE2021    时间: 2021-10-10 15:02

回复 16# cmd1152
版本1.0.0004
增加程序调试和查看源码功能
  1. @Echo Off
  2. Cls
  3. Mode Con: Cols=120 Lines=16384
  4. Color 0F
  5. Title Hope(R) Office EasyCommand EasyEnCode
  6. Chcp 936 > Nul
  7. Rem Hope(R) Office EasyCommand EasyEnCode
  8. Echo.
  9. Call :Type "  "
  10. Call :Type "#" 116
  11. Echo.
  12. Call :Type " " 55
  13. Call :Type "EasyEnCode"
  14. Echo.
  15. Call :Type "  "
  16. Call :Type "#" 116
  17. Echo.
  18. Echo.
  19. Echo.  ^>^> Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0004]
  20. Echo.  ^>^> (C) Copyright 2016-2021 Hope Corp.
  21. Echo.  ^>^> (C) Copyright 2020-2021 Hope2021 ^& Cmd1152 Corp.
  22. If "%~1"=="" (
  23. Set FileNum=1
  24. ) Else (
  25. Set FileNum=2
  26. )
  27. Md "%UserProFile%\Desktop" >Nul 2>Nul
  28. Md "%UserProFile%\桌面" >Nul 2>Nul
  29. Set "Pro=%0"
  30. Set "lnk=Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0004]"
  31. Set "Pro=%Pro:"=%"
  32. Mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Hope Office EasyCommand EasyEnCode [Version 1.0.0004].lnk""):b.TargetPath=""%Pro%"":b.WorkingDirectory=""%~dp0"":b.Save:close") >Nul 2>Nul
  33. @Goto :Main
  34. :Main
  35. Echo.
  36. Set "FileName=///*无此文件*///"
  37. If "%FileNum%"=="1" (
  38. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:
  39. ) Else (
  40. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:%~1<Nul
  41. Echo.
  42. Set FileName=%~1
  43. Set FileNum=1
  44. )
  45. Set "FileName=%FileName:"=%"
  46. For /F %%I in ('Dir /b') Do (
  47. If "%%I"=="%FileName%" (
  48. Set "FileName=%Cd%\%FileName%"
  49. )
  50. )
  51. Set FileName="%FileName%"
  52. If Not Exist %FileName% (
  53. Echo.
  54. Echo.  ^>^> 无此文件!无法加密...
  55. @Goto :Main
  56. )
  57. Set FilenameExtension=%FileName:~-5%
  58. Set FilenameExtension=%FilenameExtension:~0,4%
  59. For /L %%i in (1,1,2048) Do (
  60. If Not Exist "File-%%i\" (
  61. Md "File-%%i\" >Nul 2>Nul
  62. Set EnCodeDir=File-%%i\
  63. Set Num=%%i
  64. @Goto :EnCode
  65. )
  66. )
  67. Echo.
  68. Echo.  ^>^> 可分配的内存已经占满,无法加密...
  69. @Goto :Main
  70. :EnCode
  71. Set "Choice="
  72. If /I Not "%FilenameExtension%"==".Bat" (
  73. If /I Not "%FilenameExtension%"==".Cmd" (
  74. @Goto :Choice
  75. )
  76. )
  77. For /L %%i in (1,1,47) Do Call :RepeatBS
  78. Echo.
  79. Call :Type "  "
  80. Call :Type "+"
  81. Call :Type "=" 4
  82. Call :Type "正在加密"
  83. Call :Type "=" 4
  84. Call :Type "+"
  85. Call :Type "=" 98
  86. Echo.
  87. Echo.
  88. Echo.  开始加密时间: %Time%
  89. Echo.
  90. Echo.  文件名: %FileName%
  91. Echo.
  92. Cd %EnCodeDir%
  93. Copy %FileName% "%cd%\File.Bat" > Nul
  94. For /F %%i in ('dir /b File.Bat') do (
  95. For /L %%j in (1,1,%%~zi) do (
  96. Set /P Bytes[FileName]=%Bs%  文件大小: %%j Byte[s]<Nul
  97. )
  98. )
  99. Echo.
  100. Call :VBScript_EnCode
  101. Start /Wait "" "EnCode.VBS"
  102. If Exist "EnCode.VBS" Del "EnCode.VBS"
  103. >> "EnCode.Bat" Echo.
  104. >> "EnCode.Bat" Echo.Cls
  105. Type "File.Bat" >> "EnCode.Bat"
  106. If Exist "File.Bat" Del "File.Bat"
  107. Echo.
  108. Echo.  加密后的文件: "%Cd%\EnCode.Bat"
  109. Echo.
  110. For /F %%i in ('dir /b EnCode.Bat') do (
  111. For /L %%j in (1,1,%%~zi) do (
  112. Set /P Bytes[FileName]=%Bs%  加密后的大小: %%j Byte[s]<Nul
  113. )
  114. )
  115. Echo.
  116. Echo.
  117. Echo.  加密结束时间: %Time%
  118. Echo.
  119. Call :Type "  "
  120. Call :Type "+"
  121. Call :Type "=" 4
  122. Call :Type "=" 8
  123. Call :Type "=" 4
  124. Call :Type "+"
  125. Call :Type "=" 98
  126. Echo.
  127. Mshta VBScript:msgbox("加密%FileName:~1,-1%文件成功",64,"Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0004]")(window.close)
  128. Start Explorer "%Cd%"
  129. Start "" "Notepad" "EnCode.Bat"
  130. Echo.
  131. Echo.  ^>^> 加密完毕,是否要调试?[Y/N][输入完毕后请按下回车]
  132. Echo.
  133. Set /p "Choice=#  ^>^> "
  134. Echo.
  135. Call :Type "  "
  136. Call :Type "+"
  137. Call :Type "=" 4
  138. Call :Type "=" 8
  139. Call :Type "=" 4
  140. Call :Type "+"
  141. Call :Type "=" 98
  142. Echo.
  143. If /I Not "%Choice%"=="Y" (
  144. Cd..
  145. @Goto :Main
  146. )
  147. Start "" "EnCode.Bat"
  148. Echo.
  149. Call :Type "  "
  150. Call :Type "_" 116
  151. Echo.
  152. Call :Type "  "
  153. Call :Type "_" 4
  154. Call :Type "Code"
  155. Call :Type "_" 108
  156. Echo.
  157. Echo.
  158. More "EnCode.Bat"
  159. Echo.
  160. Call :Type "  "
  161. Call :Type "_" 116
  162. Echo.
  163. Echo.
  164. Cd..
  165. @Goto :Main
  166. :RepeatBS
  167. Set "Bs=%Bs%"
  168. @Goto :Eof
  169. :Type <Text> [Num]
  170. %=Company {Hope Studio}=%
  171. %=Author  {Hope Studio}=%
  172. If '%2'=='' (
  173. Set /p Text=#%~1<Nul
  174. @Goto :Eof
  175. )
  176. If Not '%2'=='' (
  177. For /l %%I in (1,1,%2) Do (
  178. Set /p Text=#%~1<Nul
  179. )
  180. )
  181. @Goto :Eof
  182. :VBScript_EnCode
  183. > EnCode.VBS Echo.Function WriteTextFile(strPath, text)
  184. >> EnCode.VBS Echo.With CreateObject("ADODB.Stream")
  185. >> EnCode.VBS Echo..Open
  186. >> EnCode.VBS Echo..type = 2
  187. >> EnCode.VBS Echo..WriteText text
  188. >> EnCode.VBS Echo..SaveToFile strPath
  189. >> EnCode.VBS Echo..close()
  190. >> EnCode.VBS Echo.End With
  191. >> EnCode.VBS Echo.End Function
  192. >> EnCode.VBS Echo.
  193. >> EnCode.VBS Echo.Dim EnCode
  194. >> EnCode.VBS Echo.EnCode=WriteTextFile("EnCode.Bat","")
  195. @Goto :Eof
  196. :Choice
  197. Echo.
  198. Echo.  ^>^> 此文件不是批处理文件,是否要加密?[Y/N][输入完毕后请按下回车]
  199. Echo.
  200. Set /p "Choice=#  ^>^> "
  201. If /I Not "%Choice%"=="Y" (
  202. @Goto :Main
  203. )
  204. Set "FilenameExtension=.Bat"
  205. @Goto :EnCode
复制代码

作者: HOPE2021    时间: 2021-10-10 15:11

回复 16# cmd1152
版本1.0.0005
修复了需要加密文件大小为0时的显示和加密错误
  1. @Echo Off
  2. Cls
  3. Mode Con: Cols=120 Lines=16384
  4. Color 0F
  5. Title Hope(R) Office EasyCommand EasyEnCode
  6. Chcp 936 > Nul
  7. Rem Hope(R) Office EasyCommand EasyEnCode
  8. Echo.
  9. Call :Type "  "
  10. Call :Type "#" 116
  11. Echo.
  12. Call :Type " " 55
  13. Call :Type "EasyEnCode"
  14. Echo.
  15. Call :Type "  "
  16. Call :Type "#" 116
  17. Echo.
  18. Echo.
  19. Echo.  ^>^> Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0005]
  20. Echo.  ^>^> (C) Copyright 2016-2021 Hope Corp.
  21. Echo.  ^>^> (C) Copyright 2020-2021 Hope2021 ^& Cmd1152 Corp.
  22. If "%~1"=="" (
  23. Set FileNum=1
  24. ) Else (
  25. Set FileNum=2
  26. )
  27. Md "%UserProFile%\Desktop" >Nul 2>Nul
  28. Md "%UserProFile%\桌面" >Nul 2>Nul
  29. Set "Pro=%0"
  30. Set "lnk=Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0005]"
  31. Set "Pro=%Pro:"=%"
  32. Mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Hope Office EasyCommand EasyEnCode [Version 1.0.0005].lnk""):b.TargetPath=""%Pro%"":b.WorkingDirectory=""%~dp0"":b.Save:close") >Nul 2>Nul
  33. @Goto :Main
  34. :Main
  35. Echo.
  36. Set "FileName=///*无此文件*///"
  37. If "%FileNum%"=="1" (
  38. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:
  39. ) Else (
  40. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:%~1<Nul
  41. Echo.
  42. Set FileName=%~1
  43. Set FileNum=1
  44. )
  45. Set "FileName=%FileName:"=%"
  46. For /F %%I in ('Dir /b') Do (
  47. If "%%I"=="%FileName%" (
  48. Set "FileName=%Cd%\%FileName%"
  49. )
  50. )
  51. Set FileName="%FileName%"
  52. If Not Exist %FileName% (
  53. Echo.
  54. Echo.  ^>^> 无此文件!无法加密...
  55. @Goto :Main
  56. )
  57. Set FilenameExtension=%FileName:~-5%
  58. Set FilenameExtension=%FilenameExtension:~0,4%
  59. For /L %%i in (1,1,2048) Do (
  60. If Not Exist "File-%%i\" (
  61. Md "File-%%i\" >Nul 2>Nul
  62. Set EnCodeDir=File-%%i\
  63. Set Num=%%i
  64. @Goto :EnCode
  65. )
  66. )
  67. Echo.
  68. Echo.  ^>^> 可分配的内存已经占满,无法加密...
  69. @Goto :Main
  70. :EnCode
  71. Set "Choice="
  72. If /I Not "%FilenameExtension%"==".Bat" (
  73. If /I Not "%FilenameExtension%"==".Cmd" (
  74. @Goto :Choice
  75. )
  76. )
  77. For /L %%i in (1,1,47) Do Call :RepeatBS
  78. Echo.
  79. Call :Type "  "
  80. Call :Type "+"
  81. Call :Type "=" 4
  82. Call :Type "正在加密"
  83. Call :Type "=" 4
  84. Call :Type "+"
  85. Call :Type "=" 98
  86. Echo.
  87. Echo.
  88. Echo.  开始加密时间: %Time%
  89. Echo.
  90. Echo.  文件名: %FileName%
  91. Echo.
  92. Cd %EnCodeDir%
  93. Copy %FileName% "%cd%\File.Bat" > Nul
  94. For /F %%i in ('dir /b File.Bat') do (
  95. For /L %%j in (0,1,%%~zi) do (
  96. Set /P Bytes[FileName]=%Bs%  文件大小: %%j Byte[s]<Nul
  97. )
  98. )
  99. Echo.
  100. Call :VBScript_EnCode
  101. Start /Wait "" "EnCode.VBS"
  102. If Exist "EnCode.VBS" Del "EnCode.VBS"
  103. >> "EnCode.Bat" Echo.
  104. >> "EnCode.Bat" Echo.Cls
  105. Type "File.Bat" >> "EnCode.Bat"
  106. If Exist "File.Bat" Del "File.Bat"
  107. Echo.
  108. Echo.  加密后的文件: "%Cd%\EnCode.Bat"
  109. Echo.
  110. For /F %%i in ('dir /b EnCode.Bat') do (
  111. For /L %%j in (0,1,%%~zi) do (
  112. Set /P Bytes[FileName]=%Bs%  加密后的大小: %%j Byte[s]<Nul
  113. )
  114. )
  115. Echo.
  116. Echo.
  117. Echo.  加密结束时间: %Time%
  118. Echo.
  119. Call :Type "  "
  120. Call :Type "+"
  121. Call :Type "=" 4
  122. Call :Type "=" 8
  123. Call :Type "=" 4
  124. Call :Type "+"
  125. Call :Type "=" 98
  126. Echo.
  127. Mshta VBScript:msgbox("加密%FileName:~1,-1%文件成功",64,"Hope(R) Office EasyCommand EasyEnCode [Version 1.0.0005]")(window.close)
  128. Start Explorer "%Cd%"
  129. Start "" "Notepad" "EnCode.Bat"
  130. Echo.
  131. Echo.  ^>^> 加密完毕,是否要调试?[Y/N][输入完毕后请按下回车]
  132. Echo.
  133. Set /p "Choice=#  ^>^> "
  134. Echo.
  135. Call :Type "  "
  136. Call :Type "+"
  137. Call :Type "=" 4
  138. Call :Type "=" 8
  139. Call :Type "=" 4
  140. Call :Type "+"
  141. Call :Type "=" 98
  142. Echo.
  143. If /I Not "%Choice%"=="Y" (
  144. Cd..
  145. @Goto :Main
  146. )
  147. Start "" "EnCode.Bat"
  148. Echo.
  149. Call :Type "  "
  150. Call :Type "_" 116
  151. Echo.
  152. Call :Type "  "
  153. Call :Type "_" 4
  154. Call :Type "Code"
  155. Call :Type "_" 108
  156. Echo.
  157. Echo.
  158. More "EnCode.Bat"
  159. Echo.
  160. Call :Type "  "
  161. Call :Type "_" 116
  162. Echo.
  163. Echo.
  164. Cd..
  165. @Goto :Main
  166. :RepeatBS
  167. Set "Bs=%Bs%"
  168. @Goto :Eof
  169. :Type <Text> [Num]
  170. %=Company {Hope Studio}=%
  171. %=Author  {Hope Studio}=%
  172. If '%2'=='' (
  173. Set /p Text=#%~1<Nul
  174. @Goto :Eof
  175. )
  176. If Not '%2'=='' (
  177. For /l %%I in (1,1,%2) Do (
  178. Set /p Text=#%~1<Nul
  179. )
  180. )
  181. @Goto :Eof
  182. :VBScript_EnCode
  183. > EnCode.VBS Echo.Function WriteTextFile(strPath, text)
  184. >> EnCode.VBS Echo.With CreateObject("ADODB.Stream")
  185. >> EnCode.VBS Echo..Open
  186. >> EnCode.VBS Echo..type = 2
  187. >> EnCode.VBS Echo..WriteText text
  188. >> EnCode.VBS Echo..SaveToFile strPath
  189. >> EnCode.VBS Echo..close()
  190. >> EnCode.VBS Echo.End With
  191. >> EnCode.VBS Echo.End Function
  192. >> EnCode.VBS Echo.
  193. >> EnCode.VBS Echo.Dim EnCode
  194. >> EnCode.VBS Echo.EnCode=WriteTextFile("EnCode.Bat","")
  195. @Goto :Eof
  196. :Choice
  197. Echo.
  198. Echo.  ^>^> 此文件不是批处理文件,是否要加密?[Y/N][输入完毕后请按下回车]
  199. Echo.
  200. Set /p "Choice=#  ^>^> "
  201. If /I Not "%Choice%"=="Y" (
  202. @Goto :Main
  203. )
  204. Set "FilenameExtension=.Bat"
  205. @Goto :EnCode
复制代码

作者: cmd1152    时间: 2021-10-10 15:34

回复 18# HOPE2021


    正在安装Debug...
作者: cmd1152    时间: 2021-10-10 15:55

本帖最后由 cmd1152 于 2021-10-10 15:58 编辑

Version=1.0.0005 优化+Debug 版
  1. @set "DeBug=1" %   0代表关闭DeBug,1代表打开DeBug   %
  2. @%Cmd1152提供代码优化和Debug%
  3. @Echo Off
  4.     set "Version=1.0.0005 优化+Debug 版"
  5. Cls
  6. call :Debug "修改窗口大小"
  7. Mode Con: Cols=120 Lines=16384
  8. call :Debug "修改颜色"
  9. Color 0F
  10. call :Debug "修改标题"
  11. Title Hope(R) Office EasyCommand EasyEnCode
  12. call :Debug "修改代码页"
  13. Chcp 936 > Nul
  14. Rem Hope(R) Office EasyCommand EasyEnCode
  15. Echo.
  16. call :Debug "绘图"
  17. Call :Type "  "
  18. Call :Type "#" 116
  19. Echo.
  20. Call :Type " " 55
  21. Call :Type "EasyEnCode"
  22. Echo.
  23. Call :Type "  "
  24. Call :Type "#" 116
  25. Echo.
  26. call :Debug "版权声明"
  27. Echo.
  28. Echo.  ^>^> Hope(R) Office EasyCommand EasyEnCode [Version %Version%]
  29. Echo.  ^>^> (C) Copyright 2016-2021 Hope Corp.
  30. Echo.  ^>^> (C) Copyright 2020-2021 Hope2021 ^& Cmd1152 Corp.
  31. If "%~1"=="" (
  32. Set FileNum=1
  33. ) Else (
  34. Set FileNum=2
  35. )
  36. call :Debug "新建文件夹"
  37. Md "%UserProFile%\Desktop" >Nul 2>Nul
  38. Md "%UserProFile%\桌面" >Nul 2>Nul
  39.     call :Debug "变量设置"
  40. Set "Pro=%0"
  41. Set "lnk=Hope(R) Office EasyCommand EasyEnCode [Version %Version%]"
  42. Set "Pro=%Pro:"=%"
  43. call :Debug "创建快捷方式"
  44. Mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Hope Office EasyCommand EasyEnCode [Version %Version%].lnk""):b.TargetPath=""%Pro%"":b.WorkingDirectory=""%~dp0"":b.Save:close") >Nul 2>Nul
  45. @Goto :Main
  46. :Main
  47. Echo.
  48. Set "FileName=///*无此文件*///"
  49. If "%FileNum%"=="1" (
  50. call :Debug "没有调用函数"
  51. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:
  52. ) Else (
  53.     call :Debug "有调用函数"
  54. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:%~1<Nul
  55. Echo.
  56. Set FileName=%~1
  57. Set FileNum=1
  58. )
  59. Set "FileName=%FileName:"=%"
  60.     call :Debug "查找文件"
  61. For /F %%I in ('Dir /b') Do (
  62. If "%%I"=="%FileName%" (
  63. Set "FileName=%Cd%\%FileName%"
  64. )
  65. )
  66. Set FileName="%FileName%"
  67.     call :Debug "判断文件是否存在"
  68. If Not Exist %FileName% (
  69. call :Debug "没有找到文件"
  70. Echo.
  71. Echo.  ^>^> 无此文件!无法加密...
  72. @Goto :Main
  73. )
  74. Set FilenameExtension=%FileName:~-5%
  75. Set FilenameExtension=%FilenameExtension:~0,4%
  76.     call :Debug "文件夹名字的递增"
  77. For /L %%i in (1,1,2048) Do (
  78. If Not Exist "File-%%i\" (
  79. Md "File-%%i\" >Nul 2>Nul
  80. Set EnCodeDir=File-%%i\
  81. Set Num=%%i
  82. @Goto :EnCode
  83. )
  84. )
  85.     call :Debug "文件夹超过2048"
  86. Echo.
  87. Echo.  ^>^> 可分配的内存已经占满,无法加密...
  88. @Goto :Main
  89. :EnCode
  90. Set "Choice="
  91.     call :Debug "判断文件是否是批处理"
  92. If /I Not "%FilenameExtension%"==".Bat" (
  93. call :Debug "不是.bat文件"
  94. If /I Not "%FilenameExtension%"==".Cmd" (
  95. call :Debug "不是.Cmd文件"
  96. @Goto :Choice
  97. )
  98. )
  99. call :Debug "B变量设置"
  100. For /L %%i in (1,1,47) Do Call :RepeatBS
  101.     call :Debug "绘图"
  102. Echo.
  103. Call :Type "  "
  104. Call :Type "+"
  105. Call :Type "=" 4
  106. Call :Type "正在加密"
  107. Call :Type "=" 4
  108. Call :Type "+"
  109. Call :Type "=" 98
  110. Echo.
  111.     call :Debug "[信息]"
  112. Echo.
  113. Echo.  开始加密时间: %Time%
  114. Echo.
  115. Echo.  文件名: %FileName%
  116. Echo.
  117.     call :Debug "加密过程"
  118. Cd %EnCodeDir%
  119. Copy %FileName% "%cd%\File.Bat" > Nul
  120. For /F %%i in ('dir /b File.Bat') do (
  121. For /L %%j in (0,1,%%~zi) do (
  122.     call :Debug for返回%%j,最后会返回%%~zi
  123. Set /P Bytes[FileName]=%Bs%  文件大小: %%j Byte[s] <Nul
  124. )
  125. )
  126. Echo.
  127. Call :VBScript_EnCode
  128.     call :Debug "打开EnCode.VBS,并等待运行结束"
  129. Start /W "" "EnCode.VBS"
  130.     call :Debug "删除EnCode.VBS"
  131. Del /f "EnCode.VBS" >nul 2>nul
  132.     call :Debug "写入EnCode.Bat"
  133. >> "EnCode.Bat" Echo.
  134. >> "EnCode.Bat" Echo.Cls
  135. Type "File.Bat" >> "EnCode.Bat"
  136.     call :Debug "删除File.Bat"
  137. Del /f "File.Bat" >nul 2>nul
  138.     call :Debug "[信息]"
  139. Echo.
  140. Echo.  加密后的文件: "%Cd%\EnCode.Bat"
  141. Echo.
  142. For /F %%i in ('dir /b EnCode.Bat') do (
  143. For /L %%j in (0,1,%%~zi) do (
  144.     call :Debug for返回%%j,最后会返回%%~zi
  145. Set /P Bytes[FileName]=%Bs%  加密后的大小: %%j Byte[s] <Nul
  146. )
  147. )
  148. Echo.
  149.     call :Debug "返回加密时间"
  150. Echo.
  151. Echo.  加密结束时间: %Time%
  152.     call :Debug "绘图"
  153. Echo.
  154. Call :Type "  "
  155. Call :Type "+"
  156. Call :Type "=" 4
  157. Call :Type "=" 8
  158. Call :Type "=" 4
  159. Call :Type "+"
  160. Call :Type "=" 98
  161. Echo.
  162.     call :Debug "Msg"
  163. Mshta VBScript:msgbox("加密%FileName:~1,-1%文件成功",64,"Hope(R) Office EasyCommand EasyEnCode [Version %Version%]")(window.close)
  164.     call :Debug 用资源管理器打开%CD%
  165. Start Explorer "%Cd%"
  166.     call :Debug "用记事本打开EnCode.Bat"
  167. Start "" "Notepad" "EnCode.Bat"
  168.     call :Debug "加密完毕"
  169. Echo.
  170. Echo.  ^>^> 加密完毕,是否要调试?[Y/N][输入完毕后请按下回车]
  171. Echo.
  172. Set /p "Choice=#  ^>^> "
  173. Echo.
  174.     call :Debug "绘图"
  175. Call :Type "  "
  176. Call :Type "+"
  177. Call :Type "=" 4
  178. Call :Type "=" 8
  179. Call :Type "=" 4
  180. Call :Type "+"
  181. Call :Type "=" 98
  182. Echo.
  183. If /I Not "%Choice%"=="Y" (
  184. call :Debug "返回上一级"
  185. Cd..
  186. @Goto :Main
  187. )
  188.     call :Debug "运行EnCode.Bat"
  189. Start "" "EnCode.Bat"
  190. Echo.
  191.     call :Debug "绘图"
  192. Call :Type "  "
  193. Call :Type "_" 116
  194. Echo.
  195. Call :Type "  "
  196. Call :Type "_" 4
  197. Call :Type "Code"
  198. Call :Type "_" 108
  199. Echo.
  200. Echo.
  201.     call :Debug "逐屏显示输出内容"
  202. More "EnCode.Bat"
  203. Echo.
  204.     call :Debug "绘图"
  205. Call :Type "  "
  206. Call :Type "_" 116
  207. Echo.
  208. Echo.
  209. Cd..
  210. @Goto :Main
  211. :RepeatBS
  212.     call :Debug "Bs的设置"
  213. Set "Bs=%Bs%"
  214. @Goto :Eof
  215. :Type <Text> [Num]
  216. call :Debug "绘图引擎"
  217. %=Company {Hope Studio}=%
  218. %=Author  {Hope Studio}=%
  219. If '%2'=='' (
  220. Set /p Text=#%~1<Nul
  221. @Goto :Eof
  222. )
  223. If Not '%2'=='' (
  224. For /l %%I in (1,1,%2) Do (
  225. Set /p Text=#%~1<Nul
  226. )
  227. )
  228. @Goto :Eof
  229. :VBScript_EnCode
  230. call :Debug "写入EnCode.VBS"
  231. > EnCode.VBS Echo.Function WriteTextFile(strPath, text)
  232. >> EnCode.VBS Echo.With CreateObject("ADODB.Stream")
  233. >> EnCode.VBS Echo..Open
  234. >> EnCode.VBS Echo..type = 2
  235. >> EnCode.VBS Echo..WriteText text
  236. >> EnCode.VBS Echo..SaveToFile strPath
  237. >> EnCode.VBS Echo..close()
  238. >> EnCode.VBS Echo.End With
  239. >> EnCode.VBS Echo.End Function
  240. >> EnCode.VBS Echo.
  241. >> EnCode.VBS Echo.Dim EnCode
  242. >> EnCode.VBS Echo.EnCode=WriteTextFile("EnCode.Bat","")
  243. call :Debug "写入EnCode.VBS结束"
  244. @Goto :Eof
  245. :Choice
  246.     call :Debug "[提示信息]"
  247. Echo.
  248. Echo.  ^>^> 此文件不是批处理文件,是否要加密?[Y/N][输入完毕后请按下回车]
  249. Echo.
  250. Set /p "Choice=#  ^>^> "
  251. If /I Not "%Choice%"=="Y" (
  252. @Goto :Main
  253. )
  254. call :Debug "变量FilenameExtension=.Bat"
  255. Set "FilenameExtension=.Bat"
  256. @Goto :EnCode
  257. goto :eof
  258. :Debug
  259.     if %debug%==1 (
  260.     set /P=                                                                    调试:%~1<nul
  261.     echo;
  262.     )
  263. goto :eof
复制代码

作者: cmd1152    时间: 2021-10-10 16:12

回复 17# HOPE2021


    查看源码是没有用的
作者: HOPE2021    时间: 2021-10-10 16:27

回复 21# cmd1152
查看加密的源码
作者: cmd1152    时间: 2021-10-10 16:33

回复 22# HOPE2021


    我还以为是
源码

作者: cmd1152    时间: 2021-10-11 12:40

本帖最后由 cmd1152 于 2021-10-11 12:49 编辑

Version=1.0.0005 优化+Debug+加速 版
  1. @set "DeBug=1" %   0代表关闭DeBug,1代表打开DeBug   %
  2. @%Cmd1152提供代码优化和Debug%
  3. @Echo Off
  4.     set "Version=1.0.0005 优化+Debug+加速 版"
  5. Cls
  6. call :Debug "修改窗口大小"
  7. Mode Con: Cols=120 Lines=16384
  8. call :Debug "修改颜色"
  9. Color 0F
  10. call :Debug "修改标题"
  11. Title Hope(R) Office EasyCommand EasyEnCode
  12. call :Debug "修改代码页"
  13. Chcp 936 > Nul
  14. Rem Hope(R) Office EasyCommand EasyEnCode
  15. Echo.
  16. call :Debug "绘图"
  17. Call :Type "  "
  18. Call :Type "#" 116
  19. Echo.
  20. Call :Type " " 55
  21. Call :Type "EasyEnCode"
  22. Echo.
  23. Call :Type "  "
  24. Call :Type "#" 116
  25. Echo.
  26. call :Debug "版权声明"
  27. Echo.
  28. Echo.  ^>^> Hope(R) Office EasyCommand EasyEnCode [Version %Version%]
  29. Echo.  ^>^> (C) Copyright 2016-2021 Hope Corp.
  30. Echo.  ^>^> (C) Copyright 2020-2021 Hope2021 ^& Cmd1152 Corp.
  31. If "%~1"=="" (
  32. Set FileNum=1
  33. ) Else (
  34. Set FileNum=2
  35. )
  36. call :Debug "新建文件夹"
  37. Md "%UserProFile%\Desktop" >Nul 2>Nul
  38. Md "%UserProFile%\桌面" >Nul 2>Nul
  39.     call :Debug "变量设置"
  40. Set "Pro=%0"
  41. Set "lnk=Hope(R) Office EasyCommand EasyEnCode [Version %Version%]"
  42. Set "Pro=%Pro:"=%"
  43. call :Debug "创建快捷方式"
  44. Mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Hope Office EasyCommand EasyEnCode [Version %Version%].lnk""):b.TargetPath=""%Pro%"":b.WorkingDirectory=""%~dp0"":b.Save:close") >Nul 2>Nul
  45. @Goto :Main
  46. :Main
  47. Echo.
  48. Set "FileName=///*无此文件*///"
  49. If "%FileNum%"=="1" (
  50. call :Debug "没有调用函数"
  51. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:
  52. ) Else (
  53.     call :Debug "有调用函数"
  54. Set /P FileName=#  ^>^> 请将需要加密的文件拖动至此窗体:%~1<Nul
  55. Echo.
  56. Set FileName=%~1
  57. Set FileNum=1
  58. )
  59. Set "FileName=%FileName:"=%"
  60.     call :Debug "查找文件"
  61. For /F %%I in ('Dir /b') Do (
  62. If "%%I"=="%FileName%" (
  63. Set "FileName=%Cd%\%FileName%"
  64. )
  65. )
  66. Set FileName="%FileName%"
  67.     call :Debug "判断文件是否存在"
  68. If Not Exist %FileName% (
  69. call :Debug "没有找到文件"
  70. Echo.
  71. Echo.  ^>^> 无此文件!无法加密...
  72. @Goto :Main
  73. )
  74. Set FilenameExtension=%FileName:~-5%
  75. Set FilenameExtension=%FilenameExtension:~0,4%
  76.     call :Debug "文件夹名字的递增"
  77. For /L %%i in (1,1,2048) Do (
  78. If Not Exist "File-%%i\" (
  79. Md "File-%%i\" >Nul 2>Nul
  80. Set EnCodeDir=File-%%i\
  81. Set Num=%%i
  82. @Goto :EnCode
  83. )
  84. )
  85.     call :Debug "文件夹超过2048"
  86. Echo.
  87. Echo.  ^>^> 可分配的内存已经占满,无法加密...
  88. @Goto :Main
  89. :EnCode
  90. Set "Choice="
  91.     call :Debug "判断文件是否是批处理"
  92. If /I Not "%FilenameExtension%"==".Bat" (
  93. call :Debug "不是.bat文件"
  94. If /I Not "%FilenameExtension%"==".Cmd" (
  95. call :Debug "不是.Cmd文件"
  96. @Goto :Choice
  97. )
  98. )
  99. call :Debug "B变量设置"
  100. For /L %%i in (1,1,47) Do Call :RepeatBS
  101.     call :Debug "绘图"
  102. Echo.
  103. Call :Type "  "
  104. Call :Type "+"
  105. Call :Type "=" 4
  106. Call :Type "正在加密"
  107. Call :Type "=" 4
  108. Call :Type "+"
  109. Call :Type "=" 98
  110. Echo.
  111.     call :Debug "[信息]"
  112. Echo.
  113. Echo.  开始加密时间: %Time%
  114. Echo.
  115. Echo.  文件名: %FileName%
  116. Echo.
  117.     call :Debug "加密过程"
  118. Cd %EnCodeDir%
  119. Copy %FileName% "%cd%\File.Bat" > Nul
  120. For /F %%i in ('dir /b File.Bat') do (
  121. For /L %%j in (0,2362,%%~zi) do (
  122.     call :Debug for返回%%j,最后会返回%%~zi
  123. Set /P Bytes[FileName]=%Bs%  文件大小: %%j Byte[s] <Nul
  124. )
  125.                 Set /P Bytes[FileName]=%Bs%  文件大小: %%~zi Byte[s] <Nul
  126. )
  127. Echo.
  128. Call :VBScript_EnCode
  129.     call :Debug "打开EnCode.VBS,并等待运行结束"
  130. Start /W "" "EnCode.VBS"
  131.     call :Debug "删除EnCode.VBS"
  132. Del /f "EnCode.VBS" >nul 2>nul
  133.     call :Debug "写入EnCode.Bat"
  134. >> "EnCode.Bat" Echo.
  135. >> "EnCode.Bat" Echo.Cls
  136. Type "File.Bat" >> "EnCode.Bat"
  137.     call :Debug "删除File.Bat"
  138. Del /f "File.Bat" >nul 2>nul
  139.     call :Debug "[信息]"
  140. Echo.
  141. Echo.  加密后的文件: "%Cd%\EnCode.Bat"
  142. Echo.
  143. For /F %%i in ('dir /b EnCode.Bat') do (
  144. For /L %%j in (0,2362,%%~zi) do (
  145.     call :Debug for返回%%j,最后会返回%%~zi
  146. Set /P Bytes[FileName]=%Bs%  加密后的大小: %%j Byte[s] <Nul
  147. )
  148.                 Set /P Bytes[FileName]=%Bs%  加密后的大小: %%~zi Byte[s] <Nul
  149. )
  150. Echo.
  151.     call :Debug "返回加密时间"
  152. Echo.
  153. Echo.  加密结束时间: %Time%
  154.     call :Debug "绘图"
  155. Echo.
  156. Call :Type "  "
  157. Call :Type "+"
  158. Call :Type "=" 4
  159. Call :Type "=" 8
  160. Call :Type "=" 4
  161. Call :Type "+"
  162. Call :Type "=" 98
  163. Echo.
  164.     call :Debug "Msg"
  165. Mshta VBScript:msgbox("加密%FileName:~1,-1%文件成功",64,"Hope(R) Office EasyCommand EasyEnCode [Version %Version%]")(window.close)
  166.     call :Debug 用资源管理器打开%CD%
  167. Start Explorer "%Cd%"
  168.     call :Debug "用记事本打开EnCode.Bat"
  169. Start "" "Notepad" "EnCode.Bat"
  170.     call :Debug "加密完毕"
  171. Echo.
  172. Echo.  ^>^> 加密完毕,是否要调试?[Y/N][输入完毕后请按下回车]
  173. Echo.
  174. Set /p "Choice=#  >> "
  175. Echo.
  176.     call :Debug "绘图"
  177. Call :Type "  "
  178. Call :Type "+"
  179. Call :Type "=" 4
  180. Call :Type "=" 8
  181. Call :Type "=" 4
  182. Call :Type "+"
  183. Call :Type "=" 98
  184. Echo.
  185. If /I Not "%Choice%"=="Y" (
  186. call :Debug "返回上一级"
  187. Cd..
  188. @Goto :Main
  189. )
  190.     call :Debug "运行EnCode.Bat"
  191. Start "" "EnCode.Bat"
  192. Echo.
  193.     call :Debug "绘图"
  194. Call :Type "  "
  195. Call :Type "_" 116
  196. Echo.
  197. Call :Type "  "
  198. Call :Type "_" 4
  199. Call :Type "Code"
  200. Call :Type "_" 108
  201. Echo.
  202. Echo.
  203.     call :Debug "逐屏显示输出内容"
  204. More "EnCode.Bat"
  205. Echo.
  206.     call :Debug "绘图"
  207. Call :Type "  "
  208. Call :Type "_" 116
  209. Echo.
  210. Echo.
  211. Cd..
  212. @Goto :Main
  213. :RepeatBS
  214.     call :Debug "Bs的设置"
  215. Set "Bs=%Bs%"
  216. @Goto :Eof
  217. :Type <Text> [Num]
  218. call :Debug "绘图引擎"
  219. %=Company {Hope Studio}=%
  220. %=Author  {Hope Studio}=%
  221. If '%2'=='' (
  222. Set /p Text=#%~1<Nul
  223. @Goto :Eof
  224. )
  225. If Not '%2'=='' (
  226. For /l %%I in (1,1,%2) Do (
  227. Set /p Text=#%~1<Nul
  228. )
  229. )
  230. @Goto :Eof
  231. :VBScript_EnCode
  232. call :Debug "写入EnCode.VBS"
  233. > EnCode.VBS Echo.Function WriteTextFile(strPath, text)
  234. >> EnCode.VBS Echo.With CreateObject("ADODB.Stream")
  235. >> EnCode.VBS Echo..Open
  236. >> EnCode.VBS Echo..type = 2
  237. >> EnCode.VBS Echo..WriteText text
  238. >> EnCode.VBS Echo..SaveToFile strPath
  239. >> EnCode.VBS Echo..close()
  240. >> EnCode.VBS Echo.End With
  241. >> EnCode.VBS Echo.End Function
  242. >> EnCode.VBS Echo.
  243. >> EnCode.VBS Echo.Dim EnCode
  244. >> EnCode.VBS Echo.EnCode=WriteTextFile("EnCode.Bat","")
  245. call :Debug "写入EnCode.VBS结束"
  246. @Goto :Eof
  247. :Choice
  248.     call :Debug "[提示信息]"
  249. Echo.
  250. Echo.  ^>^> 此文件不是批处理文件,是否要加密?[Y/N][输入完毕后请按下回车]
  251. Echo.
  252. Set /p "Choice=#  >> "
  253. If /I Not "%Choice%"=="Y" (
  254. @Goto :Main
  255. )
  256. call :Debug "变量FilenameExtension=.Bat"
  257. Set "FilenameExtension=.Bat"
  258. @Goto :EnCode
  259. goto :eof
  260. :Debug
  261.     if %debug%==1 (
  262.     set /P=                                                                    调试:%~1<nul
  263.     echo;
  264.     )
  265. goto :eof
复制代码

作者: cmd1152    时间: 2021-10-11 12:49

本帖最后由 cmd1152 于 2021-10-11 18:14 编辑
  1. Set /p "Choice=#  >> "
复制代码
>>不用转义
作者: cmd1152    时间: 2021-10-11 21:22

以前写的,和这个差不多是一样的,都是更改文件开头编码声明,但我这个能解密
http://www.bathome.net/viewthrea ... 6%C0%ED%BC%D3%C3%DC
作者: cmd1152    时间: 2021-10-11 21:25

你这个好像是不可逆的,能安全保护批处理
作者: xp3000    时间: 2021-10-12 16:53

回复 27# cmd1152
并不是不可逆的,这个是没有混淆可以查看
作者: cmd1152    时间: 2021-10-12 17:06

回复 28# xp3000


    升级成 混淆 的试试




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2