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

[文本处理] 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
谢谢.
Why join the navy, if you can be a pirate? - Steve Jobs

本帖最后由 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()
复制代码
Why join the navy, if you can be a pirate? - Steve Jobs

TOP

回复 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
复制代码
Why join the navy, if you can be a pirate? - Steve Jobs

TOP

回复 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
复制代码
Why join the navy, if you can be a pirate? - Steve Jobs

TOP

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

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

TOP

回复 5# HOPE2021
2. 加密方法

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

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

        #3. 将程序另存为 EasyEnCode.Bat 或 EasyEnCode.Cmd ,在命令行输入: EasyEnCode "文件名"
Why join the navy, if you can be a pirate? - Steve Jobs

TOP

回复 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
复制代码
Why join the navy, if you can be a pirate? - Steve Jobs

TOP

合作
梦依旧在,只是,心有余而力渐有不足
年年岁岁花相似,岁岁年年人不同

TOP

好家伙,自动创建快捷方式
梦依旧在,只是,心有余而力渐有不足
年年岁岁花相似,岁岁年年人不同

TOP

回复 9# cmd1152
当然,所以不支持Win2000或更早版本
Why join the navy, if you can be a pirate? - Steve Jobs

TOP

回复 10# HOPE2021


    调试器功能安装中,请不要进行更新......
梦依旧在,只是,心有余而力渐有不足
年年岁岁花相似,岁岁年年人不同

TOP

Debug安装完成

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

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

   本代码存在已经被解决的BUG,请去此楼获得代码
梦依旧在,只是,心有余而力渐有不足
年年岁岁花相似,岁岁年年人不同

TOP

抱歉,刚刚的DeBug出现了一个小问题,请稍后...
梦依旧在,只是,心有余而力渐有不足
年年岁岁花相似,岁岁年年人不同

TOP

正在优化代码并增加详细的Debug
梦依旧在,只是,心有余而力渐有不足
年年岁岁花相似,岁岁年年人不同

TOP

本帖最后由 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
复制代码
梦依旧在,只是,心有余而力渐有不足
年年岁岁花相似,岁岁年年人不同

TOP

返回列表