@@ -445,12 +445,18 @@ def _install_pkgs(self, upgrade=False, downgrade=False):
445445 if pkg .endswith ("exe" ):
446446 # Install the package
447447 log .debug ("Installing: %s" , str (pkg ))
448- batch_file = pathlib .Path (pkg ).parent / "install_nsis.cmd"
449- batch_content = f'start "" /wait "{ str (pkg )} " /start-minion=0 /S'
450- with open (batch_file , "w" ) as fp :
451- fp .write (batch_content )
452- # Now run the batch file
453- ret = self .proc .run ("cmd.exe" , "/c" , str (batch_file ))
448+ ps_cmd = (
449+ f'$p = Start-Process -FilePath "{ str (pkg )} " -ArgumentList '
450+ f'"/start-minion=0","/S" -Wait -NoNewWindow -Passthru; '
451+ f"exit $p.ExitCode"
452+ )
453+ ret = self .proc .run (
454+ "powershell.exe" ,
455+ "-ExecutionPolicy" ,
456+ "Bypass" ,
457+ "-Command" ,
458+ f"'{ ps_cmd } '" ,
459+ )
454460 self ._check_retcode (ret )
455461 elif pkg .endswith ("msi" ):
456462 # Install the package
@@ -813,12 +819,18 @@ def install_previous(self, downgrade=False):
813819 ret = self .proc .run ("cmd.exe" , "/c" , str (batch_file ))
814820 self ._check_retcode (ret )
815821 else :
816- batch_file = pkg_path .parent / "install_nsis.cmd"
817- batch_content = f'start "" /wait "{ str (pkg_path )} " /start-minion=0 /S'
818- with open (batch_file , "w" ) as fp :
819- fp .write (batch_content )
820- # Now run the batch file
821- ret = self .proc .run ("cmd.exe" , "/c" , str (batch_file ))
822+ ps_cmd = (
823+ f'$p = Start-Process -FilePath "{ str (pkg_path )} " '
824+ f'-ArgumentList "/start-minion=0","/S" -Wait -NoNewWindow '
825+ f"-Passthru; exit $p.ExitCode"
826+ )
827+ ret = self .proc .run (
828+ "powershell.exe" ,
829+ "-ExecutionPolicy" ,
830+ "Bypass" ,
831+ "-Command" ,
832+ f"'{ ps_cmd } '" ,
833+ )
822834 self ._check_retcode (ret )
823835
824836 log .debug ("Removing installed salt-minion service" )
0 commit comments