내 아래 코드는 서버 사용자 (\\10.0.1.22\C$\Logs\text.txt
)읽기 텍스트 파일
에 텍스트 파일에서 단어를 찾을 수 있습니다 : SBICAD\user
의 작업을 잘. 사용자에 대한
(SBICAD 서버의 도메인입니다) : ThisComputer\user
실패 ("로그온 실패 : 알 수없는 사용자 이름 또는 잘못된 암호")
참고 : 임 로컬 컴퓨터 XP에서 스크립트를 실행. Server 2003과 Local Machine XP는 동일한 네트워크에 있습니다.
dim objService
Set objShell = CreateObject("WScript.Shell")
strComputer = "10.0.1.22"
strDomain = "SBICAD"
Const WbemAuthenticationLevelPktPrivacy = 6
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, _
"root\cimv2:Win32_LogicalDisk='c:'", _
"administrator", _
"[email protected]", _
"MS_409", _
"ntlmdomain:" + strDomain)
objSWbemServices.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFilePath = "\\" & strComputer & "\C$\Logs\text.txt"
Set objTextFile = objFSO.OpenTextFile(strFilePath , ForReading)
Do Until objTextFile.AtEndOfStream
CurrentLine= objTextFile.ReadLine
if ((InStr(1, CurrentLine, "James", 1) > 0) And (InStr(1, CurrentLine, "John", 1) > 0))Then
Wscript.Echo "James and John Found"
end if
Loop
objTextFile.Close
당신이 옳다고 생각했습니다! 그 일 :) 당신의 위대한 적시 도움을 많이 주셔서 감사합니다. – user3186990