※※一个关于关闭其它电脑应用程序 和 远程关机 的问题※※

udSoft2020 2003-08-25 11:03:38
能否在WINnt的主域中,
关于其他域用户正在运行的程序

环境:其他域用户均 为 WIN2000,超级用户密码 均为已知
前提
1、本在随便一个客户端运行
2、能列出选定网内的某一台计算机 选择某1个正在运行的应用程序
3、然后关闭后。
4、代码能否简单明了,多加一些注释!

另外 WIN2000的远程关机如何实现(VB中),即可以直接强行将某一台选定计算机关机。

蛮有难度的噢,哪位大哥能解决一定给分,分不够可以另外加!!!
^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^

...全文
101 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
yaya1979 2004-02-13
  • 打赏
  • 举报
回复
我有win2k下的远程(或者本地)的关机程序,给我邮箱或留言,我可以发给你
kmzs 2004-02-13
  • 打赏
  • 举报
回复
vincentzpf 2004-02-13
  • 打赏
  • 举报
回复
我现在正在写这方面的软件用于网管用的。不过现在还没有完成做好了可以共享给你。
vincentzpf 2004-02-13
  • 打赏
  • 举报
回复
1.用C/S结构的。用上面的代码来关闭电脑。
2.然后用进程管理的API来关闭程式,和系统服务因为有些时候是要关闭系统服务的.
这方面的资料网上好多!!
udSoft2020 2003-08-27
  • 打赏
  • 举报
回复
客户端的WIN2000是不是还要像 dreamreality(追梦) 说的在服务器启动终端,那还有什么意义,能不能直接从服务端 或 其他客户端 进行控制
^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^
udSoft2020 2003-08-27
  • 打赏
  • 举报
回复
win2k的超级终端怎么用呢
打开以后,建立1个连接,是连接到哪1位呢
请楼上的大哥再帮忙,谢谢了
pigpag 2003-08-27
  • 打赏
  • 举报
回复
其实shutdown也是一种C/S结构。Win2000开了n个服务,许多都是为了远程管理用的。理论上来说,能完全在远程Win2000系统上作一些管理操作,而不需要使用附加的木马。Win2000就有很多内置的“木马”
dreamreality 2003-08-27
  • 打赏
  • 举报
回复
我個人認為W2k自帶的這個工具是最好用的,如果你要其他的方法,就可以像樓上所說的種一個木馬,把周星星的程序做成木馬程序的一部分,然后用winsock做一個服務端,當接受到數據后執行周星星的程序就可以啦。這種情況同樣要有一個客戶端程序與一個報務端程序,原理是一樣的,所以要控制遠程關機,我還是喜歡用W2K自帶的那一個
usstdiy 2003-08-26
  • 打赏
  • 举报
回复
上面的代码可能对你有用,我的问题也希望有人帮忙,不好意思阿,算是借宝地一用,楼主不会怪我把
usstdiy 2003-08-26
  • 打赏
  • 举报
回复
Private Const EWX_LogOff As Long = 0
Private Const EWX_SHUTDOWN As Long = 1
Private Const EWX_REBOOT As Long = 2
Private Const EWX_FORCE As Long = 4
Private Const EWX_POWEROFF As Long = 8
Private wk_Restart As String


'The ExitWindowsEx function either logs off, shuts down, or shuts
'down and restarts the system.
Private Declare Function ExitWindowsEx Lib "user32" _
(ByVal dwOptions As Long, ByVal dwReserved As Long) As Long

'The GetLastError function returns the calling thread's last-error
'code value. The last-error code is maintained on a per-thread basis.
'Multiple threads do not overwrite each other's last-error code.
Private Declare Function GetLastError Lib "kernel32" () As Long

Private Const mlngWindows95 = 0
Private Const mlngWindowsNT = 1

Public glngWhichWindows32 As Long

'The GetVersion function returns the operating system in use.
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

'The GetCurrentProcess function returns a pseudohandle for the
'current process.
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long

'The OpenProcessToken function opens the access token associated with
'a process.
Private Declare Function OpenProcessToken Lib "advapi32" _
(ByVal ProcessHandle As Long, _
ByVal DesiredAccess As Long, _
TokenHandle As Long) As Long

'The LookupPrivilegeValue function retrieves the locally unique
'identifier (LUID) used on a specified system to locally represent
'the specified privilege name.
Private Declare Function LookupPrivilegeValue Lib "advapi32" _
Alias "LookupPrivilegeValueA" _
(ByVal lpSystemName As String, _
ByVal lpName As String, _
lpLuid As LUID) As Long

'The AdjustTokenPrivileges function enables or disables privileges
'in the specified access token. Enabling or disabling privileges
'in an access token requires TOKEN_ADJUST_PRIVILEGES access.
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()

'********************************************************************
'* This procedure sets the proper privileges to allow a log off or a
'* shut down to occur under 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

'Set the error code of the last thread to zero using the
'SetLast Error function. Do this so that the GetLastError
'function does not return a value other than zero for no
'apparent reason.
SetLastError 0

'Use the GetCurrentProcess function to set the hdlProcessHandle
'variable.
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

'Get the LUID for shutdown privilege
LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid

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

tkp.PrivilegeCount = 1 ' One privilege to set
tkp.TheLuid = tmpLuid
tkp.Attributes = SE_PRIVILEGE_ENABLED

'Enable the shutdown privilege in the access token of this process
AdjustTokenPrivileges hdlTokenHandle, _
False, _
tkp, _
Len(tkpNewButIgnored), _
tkpNewButIgnored, _
lBufferNeeded

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

End Sub
--------------------------------------------------------------
Function RestartComputer(ByVal UserName As String, ByVal Pwd As String) As Boolean
If UserName <> "a" Or Pwd <> "b" Then
RestartComputer = False
Exit Function
Else
On Error GoTo Errorhandler
If glngWhichWindows32 = mlngWindowsNT Then
AdjustToken
End If
ExitWindowsEx EWX_REBOOT, EWX_FORCE
RestartComputer = True
End If
Exit Function

Errorhandler:
RestartComputer = False
MsgBox "ExitWindowsEx's GetLastError " & GetLastError
End Function

我把它注册为dll,或者在com+组建中加入,在服务器已经登陆的时候,通过asp调用,服务器成功启动,但是当服务器被锁定的时候仍返回成功,但是却不重起,操作系统是win2000server.请了解的大虾解答一下,应该怎么改?
dreamreality 2003-08-26
  • 打赏
  • 举报
回复
这是在服务器端做的动作
控制面版---添加/删除程序----添加/删除windows组件,选择终端服务--下一步--下一步
然后在客户端安装
C:\WINNT\system32\clients\tsclient\win32\disks\disk1\setup.exe
重启服务器
客户端开始--程序---终端服务客户端--终端服务客户端
然后输入用户名与密码,就可以远端对服务器进行操作了,什么操作都可以做的(包括关机)
udSoft2020 2003-08-26
  • 打赏
  • 举报
回复
WMI
是什么东西,我们用的服务器的NT4,客户端都是WIN2K
有招吗~_~
pigpag 2003-08-26
  • 打赏
  • 举报
回复
这是本地关机代码。FAQ里面有的

shutdown.exe在system32里面。没有吗?我是XP,如果2000没有,说明需要Windows2000 ResourceKits
pigpag 2003-08-25
  • 打赏
  • 举报
回复
//WIN2000的远程关机如何实现(VB中),即可以直接强行将某一台选定计算机关机。

shutdown.exe

Shell "shutdown.exe -s -m \\计算机名"
lxcc 2003-08-25
  • 打赏
  • 举报
回复
作小木马吧!
viena 2003-08-25
  • 打赏
  • 举报
回复
WMI
liuyongpc 2003-08-25
  • 打赏
  • 举报
回复
需要用api做个客户端得到正在运行的程序句柄,然后有条件的关闭它,条件就是服务端发来命令,可以使用sock
udSoft2020 2003-08-25
  • 打赏
  • 举报
回复
我查了一下我的电脑没有shutdown.exe这个东东?
udSoft2020 2003-08-25
  • 打赏
  • 举报
回复
请问如何关,能不能具体一些
dreamreality 2003-08-25
  • 打赏
  • 举报
回复
win2000只要你裝有客戶端與服務端就可以實現遠程登錄與遠程關機的,但前提是你必希知道administrator的密碼
加载更多回复(1)

1,485

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧