标题: [文本处理] 求助批处理怎样按键选择设置关机时间? [打印本页]
作者: nado 时间: 2020-11-19 19:55 标题: 求助批处理怎样按键选择设置关机时间?
我之前用这个要一个一个来点的,能不能做一个批处理按键选择,求大神帮忙!!!!无尽感激!!!
作者: 窄口牛 时间: 2020-11-19 20:55
不知道满足你不
作者: nado 时间: 2020-11-20 01:05
回复 2# 窄口牛
感谢大神了,但是这个过程有点复杂呀!我怎么感觉win10系统经常提示不能运行呢?我就算用了管理员模式
作者: ivor 时间: 2020-11-21 15:09
本帖最后由 ivor 于 2020-11-21 16:43 编辑
- #&cls&@powershell "Invoke-Expression ([Io.File]::ReadAllText('%~0',[Text.Encoding]::UTF8))" &exit
- #------------------------------------------------------------------------
- # Source File Information (DO NOT MODIFY)
- # Source ID: 4980ff6f-ceb9-4008-870a-8f1acc1982c8
- # Source File: C:\script\1.psf
- #------------------------------------------------------------------------
- #region File Recovery Data (DO NOT MODIFY)
- <#RecoveryData:
- iAMAAB+LCAAAAAAABABlk8muo1gQRPeW/A9PtUUqJmOM5HoSGDPPYKYds7GZ72Wwv77crzctda4i
- Q6nYRJ6zU2T9UkwvPoHJ10eAuu/+/CJ/47++97uvr7M51VXdJY1QN4WRtMU3/nsA5Rn9n/9zLfRT
- +910cYDbZZauB5a9mPyF/Xc4lvcbAEcCY2/3pRAWoK8JIdCUAHQ4co74uhsEfqGPntZncBwlQERY
- Uhtziyr7nQY5AVQdJtg9DEqHSfV7motOHKnyQQTBgWDrqzYX5YlYEO9l4SE9l6tiOkxZOfZCAk5v
- nmyln7yL/EmLCjxfpTeiJH2ecUJbrFaeZ5DdXpe60gxuZGLZWK1Yj4OtYkU+YEdJnKs+b7tqibjn
- ppcs1x7JI+0y+13el1hb4z1t3dboeezNiQkPGIGiMZWjMZ6HkMlQIMnIdrfDV6XAR+tVUJffGza9
- seLiYbwcqwJzfQJkv2O4VfUOuh2Yg9SEke4oE1M0VKJ0pFJmfFAVw22chIG9rmZ1ZNRIipOxRyj/
- NRyHMo3mhbgNqex01wHsd6TLUMw/leSfSkC2wEejaGg5nU5K5sc0XdZrE2/QIgeCbGOqfKu0pX/W
- 2Eey/mnNpi9Tqx9bcU4P+53gxr3vPITtPrmaFWF5ak43j3qRZqnfcQPA0B0B7U5m2KdVRvJ13PMN
- Jh/XO7SlW8haLTcpomaLiHzY72pRlfjWv0Q5um2PpAvVd6C9zC6s8qU0ctCB90Lq6tx1Ijk4bvIo
- upihQGltjNpfn4Ut8oWvzIgxNvp+F5LXJrz6JeflqePTc7EWg0xA16EHg4scc9OX6FkibJe0Rmjf
- yOBwywmfBG+zXTLUR4FOh/ChYDV1TPe7WKZ7jQyTeIrUOQqh5LrmdM0zpAvgAjbYTbWI1iPZnmzH
- K9TAWzT+ZfVSHkASD07m5+H/nNEfIH7QYAEo2rSpC/CFfpwz+l/yvv8CaK3F2IgDAAA=#>
- #endregion
-
- <#
- .NOTES
- --------------------------------------------------------------------------------
- Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
- Generated on: 2020/11/21 16:40
- Generated by: Administrator
- --------------------------------------------------------------------------------
- .DESCRIPTION
- GUI script generated by PowerShell Studio 2018
- #>
-
-
- #----------------------------------------------
- #region Application Functions
- #----------------------------------------------
-
- #endregion Application Functions
-
- #----------------------------------------------
- # Generated Form Function
- #----------------------------------------------
- function Show-1_psf {
-
- #----------------------------------------------
- #region Import the Assemblies
- #----------------------------------------------
- [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
- [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
- #endregion Import Assemblies
-
- #----------------------------------------------
- #region Generated Form Objects
- #----------------------------------------------
- [System.Windows.Forms.Application]::EnableVisualStyles()
- $form关机时间 = New-Object 'System.Windows.Forms.Form'
- $button取消关机 = New-Object 'System.Windows.Forms.Button'
- $button20分钟 = New-Object 'System.Windows.Forms.Button'
- $button10分钟 = New-Object 'System.Windows.Forms.Button'
- $button2小时 = New-Object 'System.Windows.Forms.Button'
- $button1小时 = New-Object 'System.Windows.Forms.Button'
- $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
- #endregion Generated Form Objects
-
- #----------------------------------------------
- # User Generated Script
- #----------------------------------------------
-
- $form关机时间_Load={
- #TODO: Initialize Form Controls here
-
- }
-
- $button1小时_Click={
- #TODO: Place custom script here
- cmd /c "shutdown /s /t 3600"
- }
-
- $button2小时_Click={
- #TODO: Place custom script here
- cmd /c "shutdown /s /t 7200"
- }
-
- $button10分钟_Click={
- #TODO: Place custom script here
- cmd /c "shutdown /s /t 600"
- }
-
- $button20分钟_Click={
- #TODO: Place custom script here
- cmd /c "shutdown /s /t 1200"
- }
-
- $button取消关机_Click={
- #TODO: Place custom script here
- cmd /c "shutdown /a"
- }
-
- # --End User Generated Script--
- #----------------------------------------------
- #region Generated Events
- #----------------------------------------------
-
- $Form_StateCorrection_Load=
- {
- #Correct the initial state of the form to prevent the .Net maximized form issue
- $form关机时间.WindowState = $InitialFormWindowState
- }
-
- $Form_Cleanup_FormClosed=
- {
- #Remove all event handlers from the controls
- try
- {
- $button取消关机.remove_Click($button取消关机_Click)
- $button20分钟.remove_Click($button20分钟_Click)
- $button10分钟.remove_Click($button10分钟_Click)
- $button2小时.remove_Click($button2小时_Click)
- $button1小时.remove_Click($button1小时_Click)
- $form关机时间.remove_Load($form关机时间_Load)
- $form关机时间.remove_Load($Form_StateCorrection_Load)
- $form关机时间.remove_FormClosed($Form_Cleanup_FormClosed)
- }
- catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
- }
- #endregion Generated Events
-
- #----------------------------------------------
- #region Generated Form Code
- #----------------------------------------------
- $form关机时间.SuspendLayout()
- #
- # form关机时间
- #
- $form关机时间.Controls.Add($button取消关机)
- $form关机时间.Controls.Add($button20分钟)
- $form关机时间.Controls.Add($button10分钟)
- $form关机时间.Controls.Add($button2小时)
- $form关机时间.Controls.Add($button1小时)
- $form关机时间.AutoScaleDimensions = '6, 13'
- $form关机时间.AutoScaleMode = 'Font'
- $form关机时间.ClientSize = '264, 128'
- $form关机时间.Name = 'form关机时间'
- $form关机时间.Text = '关机时间'
- $form关机时间.add_Load($form关机时间_Load)
- #
- # button取消关机
- #
- $button取消关机.Location = '96, 69'
- $button取消关机.Name = 'button取消关机'
- $button取消关机.Size = '64, 27'
- $button取消关机.TabIndex = 4
- $button取消关机.Text = '取消关机'
- $button取消关机.UseCompatibleTextRendering = $True
- $button取消关机.UseVisualStyleBackColor = $True
- $button取消关机.add_Click($button取消关机_Click)
- #
- # button20分钟
- #
- $button20分钟.Location = '21, 69'
- $button20分钟.Name = 'button20分钟'
- $button20分钟.Size = '51, 27'
- $button20分钟.TabIndex = 3
- $button20分钟.Text = '20分钟'
- $button20分钟.UseCompatibleTextRendering = $True
- $button20分钟.UseVisualStyleBackColor = $True
- $button20分钟.add_Click($button20分钟_Click)
- #
- # button10分钟
- #
- $button10分钟.Location = '173, 23'
- $button10分钟.Name = 'button10分钟'
- $button10分钟.Size = '51, 27'
- $button10分钟.TabIndex = 2
- $button10分钟.Text = '10分钟'
- $button10分钟.UseCompatibleTextRendering = $True
- $button10分钟.UseVisualStyleBackColor = $True
- $button10分钟.add_Click($button10分钟_Click)
- #
- # button2小时
- #
- $button2小时.Location = '96, 23'
- $button2小时.Name = 'button2小时'
- $button2小时.Size = '51, 27'
- $button2小时.TabIndex = 1
- $button2小时.Text = '2小时'
- $button2小时.UseCompatibleTextRendering = $True
- $button2小时.UseVisualStyleBackColor = $True
- $button2小时.add_Click($button2小时_Click)
- #
- # button1小时
- #
- $button1小时.Location = '21, 23'
- $button1小时.Name = 'button1小时'
- $button1小时.Size = '51, 27'
- $button1小时.TabIndex = 0
- $button1小时.Text = '1小时'
- $button1小时.UseCompatibleTextRendering = $True
- $button1小时.UseVisualStyleBackColor = $True
- $button1小时.add_Click($button1小时_Click)
- $form关机时间.ResumeLayout()
- #endregion Generated Form Code
-
- #----------------------------------------------
-
- #Save the initial state of the form
- $InitialFormWindowState = $form关机时间.WindowState
- #Init the OnLoad event to correct the initial state of the form
- $form关机时间.add_Load($Form_StateCorrection_Load)
- #Clean up the control events
- $form关机时间.add_FormClosed($Form_Cleanup_FormClosed)
- #Show the Form
- return $form关机时间.ShowDialog()
-
- } #End Function
-
- #Call the form
- Show-1_psf | Out-Null
复制代码
作者: binghejin 时间: 2020-11-22 14:44
我这个批处理需要放到“timing定时”文件夹内,并且文件夹内的批处理文件不能改名,否则会出错。- @echo off
- cls
- echo 定时关机
- echo ===============================
- echo 1.10分钟后关机
- echo 2.20分钟后关机
- echo 3.30分钟后关机
- echo 4.1小时后关机
- echo 5.2小时后关机
- echo 6.取消关机
- echo ===============================
- set /p v=请选择:
- if "%v%"=="1" 10分钟后关机
- if "%v%"=="2" 20分钟后关机
- if "%v%"=="3" 30分钟后关机
- if "%v%"=="4" 1小时后关机
- if "%v%"=="5" 2小时后关机
- if "%v%"=="6" 取消关机
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |