找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 20882|回复: 4

[文本处理] 求助批处理怎样按键选择设置关机时间?

[复制链接]
发表于 2020-11-19 19:55:17 | 显示全部楼层 |阅读模式
我之前用这个要一个一个来点的,能不能做一个批处理按键选择,求大神帮忙!!!!无尽感激!!!
发表于 2020-11-19 20:55:12 | 显示全部楼层
不知道满足你不
 楼主| 发表于 2020-11-20 01:05:42 | 显示全部楼层
回复 2# 窄口牛


    感谢大神了,但是这个过程有点复杂呀!我怎么感觉win10系统经常提示不能运行呢?我就算用了管理员模式
发表于 2020-11-21 15:09:36 | 显示全部楼层
本帖最后由 ivor 于 2020-11-21 16:43 编辑

  1. #&cls&@powershell "Invoke-Expression ([Io.File]::ReadAllText('%~0',[Text.Encoding]::UTF8))" &exit
  2. #------------------------------------------------------------------------
  3. # Source File Information (DO NOT MODIFY)
  4. # Source ID: 4980ff6f-ceb9-4008-870a-8f1acc1982c8
  5. # Source File: C:\script\1.psf
  6. #------------------------------------------------------------------------
  7. #region File Recovery Data (DO NOT MODIFY)
  8. <#RecoveryData:
  9. iAMAAB+LCAAAAAAABABlk8muo1gQRPeW/A9PtUUqJmOM5HoSGDPPYKYds7GZ72Wwv77crzctda4i
  10. Q6nYRJ6zU2T9UkwvPoHJ10eAuu/+/CJ/47++97uvr7M51VXdJY1QN4WRtMU3/nsA5Rn9n/9zLfRT
  11. +910cYDbZZauB5a9mPyF/Xc4lvcbAEcCY2/3pRAWoK8JIdCUAHQ4co74uhsEfqGPntZncBwlQERY
  12. Uhtziyr7nQY5AVQdJtg9DEqHSfV7motOHKnyQQTBgWDrqzYX5YlYEO9l4SE9l6tiOkxZOfZCAk5v
  13. nmyln7yL/EmLCjxfpTeiJH2ecUJbrFaeZ5DdXpe60gxuZGLZWK1Yj4OtYkU+YEdJnKs+b7tqibjn
  14. ppcs1x7JI+0y+13el1hb4z1t3dboeezNiQkPGIGiMZWjMZ6HkMlQIMnIdrfDV6XAR+tVUJffGza9
  15. seLiYbwcqwJzfQJkv2O4VfUOuh2Yg9SEke4oE1M0VKJ0pFJmfFAVw22chIG9rmZ1ZNRIipOxRyj/
  16. NRyHMo3mhbgNqex01wHsd6TLUMw/leSfSkC2wEejaGg5nU5K5sc0XdZrE2/QIgeCbGOqfKu0pX/W
  17. 2Eey/mnNpi9Tqx9bcU4P+53gxr3vPITtPrmaFWF5ak43j3qRZqnfcQPA0B0B7U5m2KdVRvJ13PMN
  18. Jh/XO7SlW8haLTcpomaLiHzY72pRlfjWv0Q5um2PpAvVd6C9zC6s8qU0ctCB90Lq6tx1Ijk4bvIo
  19. upihQGltjNpfn4Ut8oWvzIgxNvp+F5LXJrz6JeflqePTc7EWg0xA16EHg4scc9OX6FkibJe0Rmjf
  20. yOBwywmfBG+zXTLUR4FOh/ChYDV1TPe7WKZ7jQyTeIrUOQqh5LrmdM0zpAvgAjbYTbWI1iPZnmzH
  21. K9TAWzT+ZfVSHkASD07m5+H/nNEfIH7QYAEo2rSpC/CFfpwz+l/yvv8CaK3F2IgDAAA=#>
  22. #endregion

  23. <#
  24.     .NOTES
  25.     --------------------------------------------------------------------------------
  26.      Code generated by:  SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
  27.      Generated on:       2020/11/21 16:40
  28.      Generated by:       Administrator
  29.     --------------------------------------------------------------------------------
  30.     .DESCRIPTION
  31.         GUI script generated by PowerShell Studio 2018
  32. #>


  33. #----------------------------------------------
  34. #region Application Functions
  35. #----------------------------------------------

  36. #endregion Application Functions

  37. #----------------------------------------------
  38. # Generated Form Function
  39. #----------------------------------------------
  40. function Show-1_psf {

  41.         #----------------------------------------------
  42.         #region Import the Assemblies
  43.         #----------------------------------------------
  44.         [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
  45.         [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
  46.         #endregion Import Assemblies

  47.         #----------------------------------------------
  48.         #region Generated Form Objects
  49.         #----------------------------------------------
  50.         [System.Windows.Forms.Application]::EnableVisualStyles()
  51.         $form关机时间 = New-Object 'System.Windows.Forms.Form'
  52.         $button取消关机 = New-Object 'System.Windows.Forms.Button'
  53.         $button20分钟 = New-Object 'System.Windows.Forms.Button'
  54.         $button10分钟 = New-Object 'System.Windows.Forms.Button'
  55.         $button2小时 = New-Object 'System.Windows.Forms.Button'
  56.         $button1小时 = New-Object 'System.Windows.Forms.Button'
  57.         $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
  58.         #endregion Generated Form Objects

  59.         #----------------------------------------------
  60.         # User Generated Script
  61.         #----------------------------------------------
  62.        
  63.         $form关机时间_Load={
  64.                 #TODO: Initialize Form Controls here
  65.                
  66.         }
  67.        
  68.         $button1小时_Click={
  69.                 #TODO: Place custom script here
  70.                 cmd /c "shutdown /s /t 3600"
  71.         }
  72.        
  73.         $button2小时_Click={
  74.                 #TODO: Place custom script here
  75.                 cmd /c "shutdown /s /t 7200"
  76.         }
  77.        
  78.         $button10分钟_Click={
  79.                 #TODO: Place custom script here
  80.                 cmd /c "shutdown /s /t 600"
  81.         }
  82.        
  83.         $button20分钟_Click={
  84.                 #TODO: Place custom script here
  85.                 cmd /c "shutdown /s /t 1200"
  86.         }
  87.        
  88.         $button取消关机_Click={
  89.                 #TODO: Place custom script here
  90.                 cmd /c "shutdown /a"
  91.         }
  92.        
  93.         # --End User Generated Script--
  94.         #----------------------------------------------
  95.         #region Generated Events
  96.         #----------------------------------------------
  97.        
  98.         $Form_StateCorrection_Load=
  99.         {
  100.                 #Correct the initial state of the form to prevent the .Net maximized form issue
  101.                 $form关机时间.WindowState = $InitialFormWindowState
  102.         }
  103.        
  104.         $Form_Cleanup_FormClosed=
  105.         {
  106.                 #Remove all event handlers from the controls
  107.                 try
  108.                 {
  109.                         $button取消关机.remove_Click($button取消关机_Click)
  110.                         $button20分钟.remove_Click($button20分钟_Click)
  111.                         $button10分钟.remove_Click($button10分钟_Click)
  112.                         $button2小时.remove_Click($button2小时_Click)
  113.                         $button1小时.remove_Click($button1小时_Click)
  114.                         $form关机时间.remove_Load($form关机时间_Load)
  115.                         $form关机时间.remove_Load($Form_StateCorrection_Load)
  116.                         $form关机时间.remove_FormClosed($Form_Cleanup_FormClosed)
  117.                 }
  118.                 catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
  119.         }
  120.         #endregion Generated Events

  121.         #----------------------------------------------
  122.         #region Generated Form Code
  123.         #----------------------------------------------
  124.         $form关机时间.SuspendLayout()
  125.         #
  126.         # form关机时间
  127.         #
  128.         $form关机时间.Controls.Add($button取消关机)
  129.         $form关机时间.Controls.Add($button20分钟)
  130.         $form关机时间.Controls.Add($button10分钟)
  131.         $form关机时间.Controls.Add($button2小时)
  132.         $form关机时间.Controls.Add($button1小时)
  133.         $form关机时间.AutoScaleDimensions = '6, 13'
  134.         $form关机时间.AutoScaleMode = 'Font'
  135.         $form关机时间.ClientSize = '264, 128'
  136.         $form关机时间.Name = 'form关机时间'
  137.         $form关机时间.Text = '关机时间'
  138.         $form关机时间.add_Load($form关机时间_Load)
  139.         #
  140.         # button取消关机
  141.         #
  142.         $button取消关机.Location = '96, 69'
  143.         $button取消关机.Name = 'button取消关机'
  144.         $button取消关机.Size = '64, 27'
  145.         $button取消关机.TabIndex = 4
  146.         $button取消关机.Text = '取消关机'
  147.         $button取消关机.UseCompatibleTextRendering = $True
  148.         $button取消关机.UseVisualStyleBackColor = $True
  149.         $button取消关机.add_Click($button取消关机_Click)
  150.         #
  151.         # button20分钟
  152.         #
  153.         $button20分钟.Location = '21, 69'
  154.         $button20分钟.Name = 'button20分钟'
  155.         $button20分钟.Size = '51, 27'
  156.         $button20分钟.TabIndex = 3
  157.         $button20分钟.Text = '20分钟'
  158.         $button20分钟.UseCompatibleTextRendering = $True
  159.         $button20分钟.UseVisualStyleBackColor = $True
  160.         $button20分钟.add_Click($button20分钟_Click)
  161.         #
  162.         # button10分钟
  163.         #
  164.         $button10分钟.Location = '173, 23'
  165.         $button10分钟.Name = 'button10分钟'
  166.         $button10分钟.Size = '51, 27'
  167.         $button10分钟.TabIndex = 2
  168.         $button10分钟.Text = '10分钟'
  169.         $button10分钟.UseCompatibleTextRendering = $True
  170.         $button10分钟.UseVisualStyleBackColor = $True
  171.         $button10分钟.add_Click($button10分钟_Click)
  172.         #
  173.         # button2小时
  174.         #
  175.         $button2小时.Location = '96, 23'
  176.         $button2小时.Name = 'button2小时'
  177.         $button2小时.Size = '51, 27'
  178.         $button2小时.TabIndex = 1
  179.         $button2小时.Text = '2小时'
  180.         $button2小时.UseCompatibleTextRendering = $True
  181.         $button2小时.UseVisualStyleBackColor = $True
  182.         $button2小时.add_Click($button2小时_Click)
  183.         #
  184.         # button1小时
  185.         #
  186.         $button1小时.Location = '21, 23'
  187.         $button1小时.Name = 'button1小时'
  188.         $button1小时.Size = '51, 27'
  189.         $button1小时.TabIndex = 0
  190.         $button1小时.Text = '1小时'
  191.         $button1小时.UseCompatibleTextRendering = $True
  192.         $button1小时.UseVisualStyleBackColor = $True
  193.         $button1小时.add_Click($button1小时_Click)
  194.         $form关机时间.ResumeLayout()
  195.         #endregion Generated Form Code

  196.         #----------------------------------------------

  197.         #Save the initial state of the form
  198.         $InitialFormWindowState = $form关机时间.WindowState
  199.         #Init the OnLoad event to correct the initial state of the form
  200.         $form关机时间.add_Load($Form_StateCorrection_Load)
  201.         #Clean up the control events
  202.         $form关机时间.add_FormClosed($Form_Cleanup_FormClosed)
  203.         #Show the Form
  204.         return $form关机时间.ShowDialog()

  205. } #End Function

  206. #Call the form
  207. Show-1_psf | Out-Null

复制代码
发表于 2020-11-22 14:44:43 | 显示全部楼层
我这个批处理需要放到“timing定时”文件夹内,并且文件夹内的批处理文件不能改名,否则会出错。
  1. @echo off
  2. cls
  3. echo 定时关机
  4. echo ===============================
  5. echo 1.10分钟后关机
  6. echo 2.20分钟后关机
  7. echo 3.30分钟后关机
  8. echo 4.1小时后关机
  9. echo 5.2小时后关机
  10. echo 6.取消关机
  11. echo ===============================
  12. set /p v=请选择:
  13. if "%v%"=="1" 10分钟后关机
  14. if "%v%"=="2" 20分钟后关机
  15. if "%v%"=="3" 30分钟后关机
  16. if "%v%"=="4" 1小时后关机
  17. if "%v%"=="5" 2小时后关机
  18. if "%v%"=="6" 取消关机
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-20 20:32 , Processed in 0.030901 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表