"PowerShell로 실행"을 마우스 오른쪽 단추로 클릭하고 선택하여 .ps1 스크립트를 시작하더라도이 문제는 시스템 계정으로 실행되는 FileSystemWatcher와 관련된 것으로 생각합니다.FileSystemWatcher를 사용하는 PowerShell 스크립트는 Python 스크립트를 실행하지 않습니다.
주 .ps1 스크립트에 명령을 통합하고 ACTION 이벤트 중에 다른 .ps1 스크립트를 시작하여 여러 가지 방법을 시도했습니다.
두 가지 모두 백엔드 기능을 수행하거나 \ naming \ deleting 및 파일 내용을 이동하지만 .py 스크립트 실행과 관련하여 현재 세션에서는 실행되지 않습니다.
누구나 그 창을 전경에서 시작하는 방법을 알고 있습니까? Python 코드는 플러그인 Selenium을 실행하므로 Chrome을 열어야합니다.
항상 감사드립니다. 내가 그것을 알아 냈 있도록
$folder = 'C:\scripts\tmp' # root path to monitor
$filter = '*.*' # wildcard filter
$fsw = New-Object IO.FileSystemWatcher $folder, $filter -Property @{IncludeSubdirectories = $false;NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'}
Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action {
$name = $Event.SourceEventArgs.Name
$changeType = $Event.SourceEventArgs.ChangeType
$timeStamp = $Event.TimeGenerated
Write-Host "The file '$name' was $changeType at $timeStamp" -fore green
Out-File -FilePath C:\Scripts\URLwatcher\logURL.txt -Append -InputObject "The file '$name' was $changeType at $timeStamp"
#Create a timestamp var
$filetimestamp = (Get-Date -Format yyyy-mm-dd-hhmmss)
#Create a timestamp file name
$timestampedURLfile = "C:\Scripts\URLwatcher\processing\" + $filetimestamp + ".txt"
#Move URL file and rename it
move-item C:\scripts\tmp\data.txt $timestampedURLfile
#Extract & store the URL from the file
$addURL = Get-Content $filename
#Scrape the url
python C:\Scripts\DailyStats.py -l $addURL #### <--This script will not run ####
#Delete the URL file
del $filename
}