Revision 63af9c37 image_creator/os_type/windows.py
b/image_creator/os_type/windows.py | ||
---|---|---|
38 | 38 |
|
39 | 39 |
from image_creator.os_type import OSBase, sysprep |
40 | 40 |
from image_creator.util import FatalError, check_guestfs_version, get_command |
41 |
from image_creator.winexe import WinEXE, WinexeTimeout |
|
41 | 42 |
|
42 | 43 |
import hivex |
43 | 44 |
import tempfile |
... | ... | |
685 | 686 |
def _guest_exec(self, command, fatal=True): |
686 | 687 |
"""Execute a command on a windows VM""" |
687 | 688 |
|
688 |
user = "Administrator%" + self.sysprep_params['password'] |
|
689 |
addr = 'localhost' |
|
690 |
runas = '--runas=%s' % user |
|
691 |
winexe = subprocess.Popen( |
|
692 |
['winexe', '-U', user, runas, "--uninstall", "//%s" % addr, |
|
693 |
command], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
689 |
passwd = self.sysprep_params['password'] |
|
694 | 690 |
|
695 |
stdout, stderr = winexe.communicate() |
|
696 |
rc = winexe.poll() |
|
691 |
winexe = WinEXE('Administrator', passwd, 'localhost') |
|
692 |
winexe.runas('Administrator', passwd).uninstall() |
|
693 |
|
|
694 |
try: |
|
695 |
(stdout, stderr, rc) = winexe.run(command) |
|
696 |
except WinexeTimeout: |
|
697 |
FatalError("Command: `%s' timeout out." % command) |
|
697 | 698 |
|
698 | 699 |
if rc != 0 and fatal: |
699 | 700 |
reason = stderr if len(stderr) else stdout |
Also available in: Unified diff