透過伺服器自動關閉網域客戶端

透過伺服器自動關閉網域客戶端

所以這個是來自菜鳥的,請耐心等待。

所以我想每天下午 4:15 自動關閉連接到我的網域的電腦。現在我一直在窺探並發現我們可以使用 shutdown.exe 透過任務排程器來做到這一點

到目前為止一切順利,但如果我想顯示一條可愛的訊息,警告目前登入該用戶端的使用者係統將在 5 分鐘內關閉,該怎麼辦?根據我的窺探,這可以使用 VB 實現。問題是,我根本不知道那是什麼。有人可以好心地解釋一下這是什麼意思嗎?

謝謝你能做到這一步:)

答案1

VB 是(Visual Basic Sc​​ript)的縮寫,以下是執行 VB 來執行任務的程式碼。代碼參考

步驟 1) 下載文字編輯器將程式碼放入點這裡

步驟 2) 將下列程式碼複製並貼上到文字編輯器中

步驟3)點擊文件然後另存為-暫時不要點擊“儲存”

步驟 4) 確保您有另存為類型設定所有類型

步驟 5) 致電檔案名稱 遠端關機.vbs-不要忘記.vbs!

步驟6)點擊文件然後打開包含資料夾然後單擊探險家

步驟 7) 雙擊您剛剛建立的腳本!

步驟 8) 當腳本詢問你時“在哪台計算機上執行操作?”輸入您想要控制的網路上的電腦名稱。

步驟 9) 回答下一個問題的 2

步驟 10) 找到一個可以學習如何使用 VBScript 進行程式設計的網站從這裡開始

下面是記事本++中的程式碼

strComputer=InputBox("Perform action on what computer?","Enter Computer 
Name",strComputer)  

'if no computername is specified (blank), then quit  
If strComputer = "" Then WScript.Quit  

strComputer = UCase(strComputer)  


RestartMode = InputBox("I would like to perform the following action on " & 
strComputer & ":" & vbcrlf & vbcrlf _  
 & "0 - Restart " & strComputer & vbcrlf _  
 & "1 - Logoff " & strComputer & vbcrlf _  
 & "2 - Shutdown " & strComputer & vbcrlf _  
 & "3 - Do nothing " & vbcrlf _  
 & vbcrlf,"Restart action",RestartMode)  

If RestartMode = "" Then  
   wscript.quit  
ElseIf RestartMode < 0 or Restartmode > 3 Then  
   wscript.echo "You must select a valid option between 0 and 3.  Script will now 
exit."  
   wscript.quit  
End If  

'You could also remove the above lines and declare your variables like this:  
' strComputer = "computername"  
' RestartMode = 1  
'0 = restart, 1 = logoff, 2 = shutdown, 3 = do nothing  
'also, with a little work, you could easily make command-line arguments for this  

Call RestartAction  

Sub RestartAction  
   Dim OpSysSet, OpSys  

   Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//"_  
    & strComputer & "/root/cimv2").ExecQuery("select * from Win32_OperatingSystem"_  
    & " where Primary=true")  

   'set PC to reboot  
   If RestartMode = 0 Then  

      For each OpSys in OpSysSet  
         opSys.Reboot()  
      Next  

   'set PC to logoff  
   ElseIf RestartMode = 1 Then  

      Const EWX_LOGOFF = 0  
      For each OpSys in OpSysSet  
          opSys.win32shutdown EWX_LOGOFF  
      Next  

   'set PC to shutdown  
   ElseIf RestartMode = 2 Then  

      For each OpSys in OpSysSet  
         opSys.Shutdown()  
      Next  

   'set PC to do nothing  
   ElseIf RestartMode = 3 Then  


   End If  
End Sub

相關內容