应科苑 www.jxuz.net
静音模式
应科电台
应科网络电台 | 感恩节祝福 |分数查询 | 加入收藏 | 设为首页 | 论坛帮助 | 联系我们
打印

[原创] 让你的电脑实现自动关机

让你的电脑实现自动关机

╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
    ┋                超实用批处理命令   。。。   科苑 wWw.JxUz..NeT        ┋                  
    ┋    输入 1 打开vista特效            输入 2  关闭vista特效                                                                                                      

   ┋    输入 3 进入 应科苑论坛          输入 4  进入 网络下载               ┋                                             
    ┋    输入 5 进入 高清影院            输入 6  15分钟后自动关机            ┋  
    ┋    输入 7 30分钟后自动关机         输入 8  45分钟后自动关机            ┋                                                 输入 q  退出  
    ┋                                         应科苑论坛  ╰☆甘^ǒ^冰☆ゞ 制作┋                          
    ╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝

附件: 您所在的用户组无法下载或查看附件
小强 抛锚 休整一下 离开几天

TOP

@echo off
color 5f
@echo   ╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
@echo   ┋                超实用批处理命令   。。。   应科苑 wWw.JxUz..NeT        ┋                  
@echo   ┋    输入 1 打开vista特效            输入 2  关闭vista特效                                                                                                      

@echo   ┋    输入 3 进入 应科苑论坛          输入 4  进入 网络下载               ┋                                             
@echo   ┋    输入 5 进入 高清影院            输入 6  15分钟后自动关机            ┋  
@echo   ┋    输入 7 30分钟后自动关机         输入 8  45分钟后自动关机            ┋                                                 输入 q  退出  
@echo   ┋                                         应科苑论坛  ╰☆甘^ǒ^冰☆ゞ 制作┋                          
@echo   ╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝

set a=
set/p a=1,2,3,4,5,6,7,8,Q请选择输入。。。
if "%a%"=="1" Rundll32 dwmApi #102
if "%a%"=="2" Rundll32 dwmApi #104
if "%a%"=="3" start http://www.jxuz.net
if "%a%"=="4" start http://dvd.0797dx.cn
if "%a%"=="5" start http://vod.0797dx.cn
if "%a%"=="6" Shutdown.exe –s –t 900
if "%a%"=="7" Shutdown.exe –s –t 1800
if "%a%"=="8" Shutdown.exe –s –t 2700
if "%a%"=="q" exit
goto loop

这个好象xp/2000系统行不通吧

TOP

哇,看不懂其它符号

TOP

使用Shutdown.exe命令的时候总在怀念冲击波的日子

批处理的命令行写出来是没有美感可言
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.

TOP

回复 2楼 的帖子

可以说会受限制
XP有Shutdown.exe的
2000好像没有
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.

TOP

0.0
阿?!
以前我就在想终于自动关机,
我用迅雷下载以及一些杀毒软件可以设置完成后关机,
为什么⒏能设置自动关机?!
>.<
现在才知道原来真的有自动关机的办法额...
改天试验下...
____________) 愛的,⒏愛的,一直都在告别中...

TOP

Option Explicit
Dim mytime
Dim nowtime
Dim i, t As Long
Const EWX_SHUTDOWN = 1
'GetLastError函数返回本线程的最后一次错误代码。错误代码是按照线程
'储存的,多线程也不会覆盖其他线程的错误代码。
Private Declare Function GetLastError Lib "kernel32" () As Long

Private Const mlngWindows95 = 0
Private Const mlngWindowsNT = 1

Public glngWhichWindows32 As Long
' GetVersion返回操作系统的版本。
Private Declare Function GetVersion Lib "kernel32" () As Long

Private Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long
End Type

Private Type LUID_AND_ATTRIBUTES
TheLuid As LUID
Attributes As Long
End Type

Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End Type

'GetCurrentProcess函数返回当前进程的一个句柄。
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long

'OpenProcessToken函数打开一个进程的访问代号。
Private Declare Function OpenProcessToken Lib "advapi32" _
(ByVal ProcessHandle As Long, _
ByVal DesiredAccess As Long, _
TokenHandle As Long) As Long

'LookupPrivilegeValue函数获得本地唯一的标示符(LUID),用于在特定的系统中
'表示特定的优先权。
Private Declare Function LookupPrivilegeValue Lib "advapi32" _
Alias "LookupPrivilegeValueA" _
(ByVal lpSystemName As String, _
ByVal lpName As String, _
lpLuid As LUID) As Long

'AdjustTokenPrivileges函数使能或者禁用指定访问记号的优先权。
'使能或者禁用优先权需要TOKEN_ADJUST_PRIVILEGES访问权限。
Private Declare Function AdjustTokenPrivileges Lib "advapi32" _
(ByVal TokenHandle As Long, _
ByVal DisableAllPrivileges As Long, _
NewState As TOKEN_PRIVILEGES, _
ByVal BufferLength As Long, _
PreviousState As TOKEN_PRIVILEGES, _
ReturnLength As Long) As Long

Private Declare Sub SetLastError Lib "kernel32" _
(ByVal dwErrCode As Long)

Private Sub AdjustToken()

'********************************************************************
'* 这个过程设置正确的优先权,以允许在Windows NT下关机或者重新启动。
'********************************************************************

Const TOKEN_ADJUST_PRIVILEGES = &H20
Const TOKEN_QUERY = &H8
Const SE_PRIVILEGE_ENABLED = &H2

Dim hdlProcessHandle As Long
Dim hdlTokenHandle As Long
Dim tmpLuid As LUID
Dim tkp As TOKEN_PRIVILEGES
Dim tkpNewButIgnored As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long

'使用SetLastError函数设置错误代码为0。
'这样做,GetLastError函数如果没有错误会返回0
SetLastError 0

' GetCurrentProcess函数设置 hdlProcessHandle变量
hdlProcessHandle = GetCurrentProcess()

If GetLastError <> 0 Then
MsgBox "GetCurrentProcess error==" & GetLastError
End If

OpenProcessToken hdlProcessHandle, _
(TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY), hdlTokenHandle

If GetLastError <> 0 Then
MsgBox "OpenProcessToken error==" & GetLastError
End If

' 获得关机优先权的LUID
LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid

If GetLastError <> 0 Then
MsgBox "LookupPrivilegeValue error==" & GetLastError
End If

tkp.PrivilegeCount = 1 ' 设置一个优先权
tkp.TheLuid = tmpLuid
tkp.Attributes = SE_PRIVILEGE_ENABLED

' 对当前进程使能关机优先权
AdjustTokenPrivileges hdlTokenHandle, _
False, _
tkp, _
Len(tkpNewButIgnored), _
tkpNewButIgnored, _
lBufferNeeded

If GetLastError <> 0 Then
MsgBox "AdjustTokenPrivileges error==" & GetLastError
End If

End Sub

这个是VB程序实现自动关机的比较核心的代码
本帖最近评分记录

TOP

楼上贴的更实用
是程序员的思路
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.

TOP

网上流行的思路,弄成一个模块可以方便套用,可以适用现在的XP系统,visita不知道了估计不行

TOP