我想創建一個程序,回聲的當前用戶。程序使用任務調度程序,回聲用戶,同時作爲管理員運行
由於程序需要使用任務調度程序作爲管理員運行,%username%始終返回admin,而不是用戶。
什麼,我到底追求的是呼應的時間戳,用戶信息和計算機信息每次用戶登錄開,關,鎖,解鎖時間批,切換用戶,...
我想創建一個程序,回聲的當前用戶。程序使用任務調度程序,回聲用戶,同時作爲管理員運行
由於程序需要使用任務調度程序作爲管理員運行,%username%始終返回admin,而不是用戶。
什麼,我到底追求的是呼應的時間戳,用戶信息和計算機信息每次用戶登錄開,關,鎖,解鎖時間批,切換用戶,...
我遇到類似問題之前,請嘗試使用whoami
當前用戶是管理員。 Windows支持多個用戶(儘管每次只能有一個用戶)。你可以做的是查詢用戶登錄並選擇交互式的。潛在用戶的
列表
wmic PATH Win32_SystemUsers get /format:List
wmic PATH WIN32_UserAccount get /format:List
wmic PATH WIN32_Account get /format:List
所有用戶登錄系統含賬戶。 NB管理員將有兩個登錄 - 一個是限制用戶,另一個是提升。
wmic PATH Win32_LoggedOnUser get /format:List
要查找有關的登錄類型登錄類型的
wmic PATH Win32_LogonSession get /format:list
列表信息 - 你想2.
LogonTypeData type: uint32Access type: Read-only
Numeric value that indicates the type of logon session.
Value
Meaning
0
Used only by the System account.
Interactive2
Intended for users who are interactively using the machine, such as a user being logged on by a terminal server, remote shell, or similar process.
Network3
Intended for high-performance servers to authenticate clear text passwords. LogonUser does not cache credentials for this logon type.
Batch4
Intended for batch servers, where processes can be executed on behalf of a user without their direct intervention; or for higher performance servers that process many clear-text authentication attempts at a time, such as mail or web servers. LogonUser does not cache credentials for this logon type.
Service5
Indicates a service-type logon. The account provided must have the service privilege enabled.
Proxy6
Indicates a proxy-type logon.
Unlock7
This logon type is intended for GINA DLLs logging on users who are interactively using the machine. This logon type allows a unique audit record to be generated that shows when the workstation was unlocked.
NetworkCleartext8
Preserves the name and password in the authentication packages, allowing the server to make connections to other network servers while impersonating the client. This allows a server to accept clear text credentials from a client, call LogonUser, verify that the user can access the system across the network, and still communicate with other servers.
NewCredentials9
Allows the caller to clone its current token and specify new credentials for outbound connections. The new logon session has the same local identify, but uses different credentials for other network connections.
RemoteInteractive10
Terminal Services session that is both remote and interactive.
CachedInteractive11
Attempt cached credentials without accessing the network.
CachedRemoteInteractive12
管理員權限不需要任何的信息輸出的。它看起來像環境變量__DATE__,__TIME__,__USERNAME__和__COMPUTERNAME__提供您想要輸出的所有數據。請發佈已有的代碼並添加更多詳細信息以獲得更好的幫助。 – Mofi
代碼確實需要以管理員身份運行,因爲寫入txt存儲在安全服務器中。 –
@echo off cls echo%date%%time%%username%%computername%>> \\ ****** \ _ AD_Logon_Timestamp \%computername%.txt –