powershell 通过IE下载文件
in 技术分享工具收集 with 0 comment

powershell 通过IE下载文件

in 技术分享工具收集 with 0 comment
$ie = New-Object -Com internetExplorer.Application
$ie.Navigate("https://site.com/somefile")

#------------------------------
#Wait for Download Dialog box to pop up
Sleep 5
while($ie.Busy){Sleep 1}
#------------------------------

#Hit "S" on the keyboard to hit the "Save" button on the download box
$obj = new-object -com WScript.Shell
$obj.AppActivate('Internet Explorer')
$obj.SendKeys('s')

#Hit "Enter" to save the file
$obj.SendKeys('{Enter}')

#Closes IE Downloads window
$obj.SendKeys('{TAB}')
$obj.SendKeys('{TAB}')
$obj.SendKeys('{TAB}')
$obj.SendKeys('{Enter}')

原文:戳我

Responses