Wie starte ich eine Windows XP Virtual PC-Anwendung mit Powershell unter Windows 7?

Wie starte ich eine Windows XP Virtual PC-Anwendung mit Powershell unter Windows 7?

Dies ist ein Verknüpfungsziel einer Anwendung, die ich unter Windows 7 starte und die ein Programm im Windows XP-Modus startet.

%SystemRoot%\system32\rundll32.exe %SystemRoot%\system32\VMCPropertyHandler.dll,LaunchVMSal "Windows XP Mode" "||fc9407e9" "wIntegrate"

Ich schaffe es nicht, den PS-Start-Prozessbefehl für dieses Ziel zum Laufen zu bringen.

Von mir verwendeter Code:

Start-Process %SystemRoot%\system32\rundll32.exe %SystemRoot%\system32\VMCPropertyHandler.dll,LaunchVMSal "Windows XP Mode" "||fc9407e9" "wIntegrate"

Hier ist die Fehlermeldung, die ich erhalte:

Start-Process : A positional parameter cannot be found that accepts argument 'Windows XP Mode'.
At C:\Users\username.domain\Desktop\rebootpick.ps1:13 char:14
+ Start-Process <<<<  %SystemRoot%\system32\rundll32.exe %SystemRoot%\system32\VMCPropertyHandler.dll,LaunchVMSal "Windows XP Mode" "||fc9407e9" "wIntegrate"
    + CategoryInfo          : InvalidArgument: (:) [Start-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

Hat jemand erfolgreich Anwendungen im Windows XP-Modus über Powershell unter Windows 7 ausgeführt?

Antwort1

Das hier sollte es für Sie erledigen:

$sysRoot = get-content env:systemroot;
Start-Process $sysRoot\system32\rundll32.exe -ArgumentList "$sysRoot\system32\VMCPropertyHandler.dll,LaunchVMSal `"Windows XP Mode`" `"||fc9407e9`" `"wIntegrate`"";
Remove-Variable sysRoot;

Erster Trick: %systemroot% funktioniert nicht in PS, also weisen wir eine Variable ($sysRoot) zu, um diese Umgebungsvariable in PS zu erhalten.

Der nächste Trick besteht darin, zu erkennen, dass RunDLL32 nur ein Argument zur Verfügung steht und dieses Argument Argumente hat. Daher müssen wir alle Teile des Arguments in Anführungszeichen in ein Argument einschließen. Aber wir müssen die vorhandenen Anführungszeichen in diesem Argument beibehalten, also maskieren wir sie mit `.

Hoffentlich hilft das...

verwandte Informationen