一分钟后关机输入正确密码取消关机如何实现
Tofloor
poster avatar
yfd11
deepin
2018-06-10 22:56
Author
本帖最后由 yfd11 于 2018-6-11 15:40 编辑

如题:一分钟后关机输入正确密码取消关机如何实现
shutdown -h 1
1分钟后关机命令
shutdown -c
取消关机命令
找到可以输入输出的对话框地址
https://www.linuxprobe.com/create-interactive-shell-script.html?jimmo7860

windows10系统 我的是这样的在桌面建一个  VBS倒计时5分钟但输入正确密码可不关机.VBS   内容
set ws=wscript.createobject("wscript.shell")
ws.run "shutdown -s -t 60",0
do while i<>"12345"
i=inputbox("密码正确就可以解除关机!","请输入密码!")
loop
ws.run "shutdown -a",0
msgbox "密码正确,关机解除!"

再新建个BAT 名为 计划任务以管理员运行.bat 内容
::以管理员运行该程序
schtasks /create /tn "系统启动时启动5分钟后关机1" /tr "E:\yfd\桌面\VBS倒计时5分钟但输入正确密码可不关机.VBS" /sc onstart /ru %username% /rp ""
::schtasks /create /tn "系统启动时启动5分钟后关机1" /tr "E:\yfd\桌面\VBS倒计时5分钟但输入正确密码可不关机.VBS" /sc onstart /ru ""
::schtasks /create /tn "系统启动时启动5分钟后关机" /tr "E:\yfd\桌面\VBS倒计时5分钟但输入正确密码可不关机.VBS" /sc onstart /ru System
::schtasks /create /tn "系统启动时启动5分钟后关机2" /tr "E:\yfd\桌面\VBS倒计时5分钟但输入正确密码可不关机.VBS" /sc onstart /ru %username% /rp ""
::schtasks /change /tn "系统启动时启动5分钟后关机2" /ru ""
pause

桌面重定位了所以地址为E:\yfd\桌面 这个地址
右键文件 计划任务以管理员运行.bat 以管理员身份运行 即重启系统引到到WIN10,1分钟后自动关机了。登不登陆用户都会关机
进系统后弹出1分钟后关机时可双击运行 VBS倒计时5分钟但输入正确密码可不关机.VBS 运行输入12345回车就取消关机了。

但LINUX系统不知在哪添加自启动,搜索按方法还是不能用。


Reply Favorite View the author
All Replies
avatar
wtz
deepin
2018-06-11 00:55
#1
楼主需要图形化界面还是命令行界面?
Reply View the author
avatar
yfd11
deepin
2018-06-11 16:01
#2
https://bbs.deepin.org/post/157953
楼主需要图形化界面还是命令行界面?

最好是图形化界面,不过命令行界面也行
Reply View the author
avatar
wtz
deepin
2018-06-12 11:51
#3
本帖最后由 wtz 于 2018-6-12 03:56 编辑

自启动命令可以添加在 /etc/rc.local 文件中(如果没有请手动创建:  sudo touch /etc/rc.local  ),但有两点需要注意:
1、所有命令都要位于 “exit 0”这一行前,否则不会被执行。
2、需要赋予 /etc/rc.local 这个文件可执行权限(命令: sudo chmod +x /etc/rc.local ),否则不会被执行。
Reply View the author
avatar
ritter
deepin
2018-06-12 15:01
#4
这个直接taskkill掉,然后手动shutdown -c不就行了?这个只能防君子啊。
Reply View the author
avatar
yfd11
deepin
2018-06-21 22:16
#5
本帖最后由 yfd11 于 2018-6-21 14:23 编辑
https://bbs.deepin.org/post/157953
自启动命令可以添加在 /etc/rc.local 文件中(如果没有请手动创建:  sudo touch /etc/rc.local  ),但有 ...

rc.local内容为以下,好像还是不能1分钟关闭电脑
shutdown -h 1
exit 0系统版本为15.6桌面版
yewanfu1@yewanfu1-PC:~$ more /etc/rc.local
shutdown -h 1
exit 0


Reply View the author
avatar
yfd11
deepin
2018-06-21 22:17
#6
https://bbs.deepin.org/post/157953
这个直接taskkill掉,然后手动shutdown -c不就行了?这个只能防君子啊。

是的,我只是为了防止电脑启动不关机,不是防止他人用电脑的。
Reply View the author
avatar
wtz
deepin
2018-06-21 22:53
#7
https://bbs.deepin.org/post/157953
rc.local内容为以下,好像还是不能1分钟关闭电脑
shutdown -h 1
exit 0系统版本为15.6桌面版

先确定 /etc/rc.local 有可执行权限:
  1. ls -al /etc/rc.local
Copy the Code

然后将 rc-local.service 设为开机启动:
  1. sudo systemctl enable rc-local.service
Copy the Code
Reply View the author
avatar
yfd11
deepin
2018-06-23 16:56
#8
https://bbs.deepin.org/post/157953
先确定 /etc/rc.local 有可执行权限:

然后将 rc-local.service 设为开机启动:

yewanfu1@yewanfu1-PC:~$ ls -al /etc/rc.local
-rwxrwxrwx 1 root root 22 6月  21 14:06 /etc/rc.local

ewanfu1@yewanfu1-PC:~$ sudo systemctl enable rc-local.service
The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
   instance name specified.
yewanfu1@yewanfu1-PC:~$ systemctl list-units --type=service

  UNIT                            LOAD   ACTIVE SUB     DESCRIPTION  
● rc-local.service                loaded failed failed  /etc/rc.local Compatibilit

Reply View the author
avatar
wtz
deepin
2018-06-24 00:06
#9
https://bbs.deepin.org/post/157953
yewanfu1@yewanfu1-PC:~$ ls -al /etc/rc.local
-rwxrwxrwx 1 root root 22 6月  21 14:06 /etc/rc.local ...

啊抱歉,忘了 rc.local.servive 是不需要enable的。

你在你的 rc.local 文件最顶端插入一行:
  1. #!/bin/bash
Copy the Code

看看行不行。如果还是不行,就在exit 0那一行前面再插一行:
  1. echo "Test" > /tmp/test.txt
Copy the Code

然后重启,看看 /tmp 目录下面有没有出现 test.txt 这个文件。如果有,就说明 rc.local 其实已经被执行了,只不过shutdown命令没有发挥作用。
Reply View the author
avatar
yfd11
deepin
2018-06-24 18:12
#10
本帖最后由 yfd11 于 2018-6-24 15:07 编辑
https://bbs.deepin.org/post/157953
啊抱歉,忘了 rc.local.servive 是不需要enable的。

你在你的 rc.local 文件最顶端插入一行:

好像现在可以了但进系统密码错误了  不知怎么回事(没有更改过密码),又要下系统重装了(笨人的方法只能那样了呢),谢谢您了wtz再次重装系统,还是老问题登陆密码错误了,没改过密码。
Reply View the author
avatar
yfd11
deepin
2018-12-08 20:06
#11
一直没弄过现在换了15.8版本还是老问题进系统密码登陆不了了(没改过密码),是什么原因呢。
Reply View the author