嘿,任何人都可以告诉我如何打开电源点并播放幻灯片
我有以下代码,但它无法正常工作
$ppAdvanceOnTime = 2
$ppShowTypeKiosk = 3
$ppSlideShowDone = 5
Add-type -AssemblyName office
$Application = New-Object -ComObject powerpoint.application
$application.visible = [Microsoft.Office.Core.MsoTriState]::msoTrue
$path = "C:\Users\asuribha\Desktop\Web.pptx"
$presentation = $application.Presentations.open($path)
$presentation.SlideShowSettings.AdvanceMode = $ppAdvanceOnTime
$presentation.SlideShowSettings.ShowType = $ppShowTypeKiosk
$presentation.SlideShowSettings.StartingSlide = 1
$presentation.SlideShowSettings.EndingSlide = $presentation.Slides.Count
Do
{
$presenatation.SlideShowSettings.Run.View.
if (Err<>0)
{
Exit Do
}
}
until ($presenatation.SlideShowSettings.Run.View.State = $ppSlideShowDone)
$application.quit()
[gc]::collect()
[gc]::WaitForPendingFinalizers()
此代码打开电源点但不播放幻灯片!我也有一个问题,它有时会自动关闭电源点。 请帮我解决这个问题
答案 0 :(得分:3)
我在各个网站上遇到了很多问题并最终发现这是最快的,即使powerpoint没有运行它仍然能够继续运行的机器也没有问题。我基本上想要运行一个脚本,接待员可以输入详细信息,而不需要任何复杂的输入框然后在完成它时会在演示屏幕上运行另一个PowerShell。
这是接待员输入powershell输入。
Add-Type -AssemblyName Microsoft.VisualBasic
$PPTFile = [Microsoft.VisualBasic.Interaction]::InputBox('Enter FileName', 'Powerpoint File', "$env")
$pptx = "d:\Presentations"+($pptfile)+".pptx"
$pptx | Out-File "\\(machine name)\Scripts\Powerpoint.txt"
我可以稍后通过远程运行powershell来简化它,但是目前作为一个PowerShell新手我在另一端运行另一个脚本并且运行良好。
Stop-Process -name "POWERPNT"
$Power = Get-Content "d:\Scripts\Powerpoint.txt"
write-output $Power
$powerptx = "/s "+($Power)
start-process powerpnt.exe -ArgumentList“$ powerptx”
答案 1 :(得分:0)
所以我不是PowerShell的忠实粉丝,但是我使用这个脚本在我们拥有的监视器上旋转演示文稿:
$ppt = "c:\presentation.pptx"
$new_file = "c:\new.pptx"
function runloop {
$running = get-process POWERPNT
$killed = $false
if (Test-Path $new_file) {
Write-Host "Killing"
kill -name POWERPNT
Start-Sleep -s 2
Move-Item $new_file $ppt -force
$killed = $true
}
if (!$running -or $killed) {
Write-Host "Not running"
$app = New-Object -ComObject powerpoint.application
$pres = $app.Presentations.open($ppt)
$app.visible = "msoTrue"
$pres.SlideShowSettings.Run()
$pres.visible = "msoTrue"
}
Write-Host "Done"
}
runloop;
Hacky,但它对我有用。希望这会有所帮助。