0
當談到PowerShell腳本時,我是一個完整的新手,但在編寫Bat文件方面有合理的經驗。Powershell/Bat文件合併
我有一個PowerShell腳本解壓縮蝙蝠,reg文件和msi,powershell腳本然後啓動bat文件,我不認爲這是最好的方式來做到這一點,有沒有辦法只是得到powershell腳本解壓縮,然後安裝msi和reg文件,而不是運行一個單獨的bat文件?
這裏有2個文件:
BAT:
@echo off
echo Installing Teamviewer, please wait...
msiexec /qn /i "C:\Temp\TeamViewer.msi" /passive
echo[
regedit /s C:\Temp\TeamViewer_Settings.reg
Pause
exit
PS:
$BackUpPath = "C:\Temp\Install.zip"
$Destination = "C:\Temp"
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::ExtractToDirectory($BackUpPath, $destination)
Start-Process "C:\Temp\installer.bat"
有沒有辦法只運行PowerShell腳本並提取並安裝所需要的文件?
非常感謝和善良,這是我的第一個PowerShell腳本。
嗨基蘭,謝謝!這就說得通了!不知道爲什麼我不能一個人解決這個問題。 我現在收到此錯誤: 文件C:\ Temp \ tps.ps1無法加載。文件C:\ Temp \ tps.ps1未進行數字簽名。你不能在當前系統上運行這個 腳本。有關運行腳本和設置執行策略的更多信息,請參閱 about_Execution_Policies,網址爲http://go.microsoft.com/fwlink/?LinkID=135170。 + CategoryInfo:SecurityError:(:) [],ParentContainsErrorRecordException + FullyQualifiedErrorId:UnauthorizedAccess 如何簽署腳本以便它運行? –
歡迎標記....錯誤表明您的計算機上的執行策略設置爲'allsigned',這意味着每個ps腳本在執行之前都需要進行簽名....雖然這是最安全的選項,但大多數人將執行策略設置爲'remotesigned' .. ...檢查此鏈接以獲取更多詳細信息:https://technet.microsoft.com/en-us/library/ee176961.aspx?f = 255&MSPPError = -2147217396 ...注意:.launch powershell作爲管理員 – Kiran
也是這個鏈接如何簽署腳本.....'https:// technet.microsoft.com/en-us/magazine/2008.04.powershell.aspx' – Kiran