How to start a Windows XP Virtual PC application using Powershell from Windows 7?

3

1

This is a shortcut target of an application I launch from Windows 7 that starts a program in Windows XP Mode.

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

I can't seem to get the PS Start-process command to work for that target.

Code I use:

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

Here is the error I receive:

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

Has anyone had any luck executing Windows XP Mode applications from Powershell from Windows 7?

payling

Posted 2012-01-23T20:07:58.800

Reputation: 167

Can you include the actual PS code you are using to launch it? – Ƭᴇcʜιᴇ007 – 2012-01-23T20:26:11.860

Added, see question. – payling – 2012-01-23T20:30:21.540

Answers

5

This should do it for you:

$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;

First trick: %systemroot% doesn't work in PS, so we assign a variable ($sysRoot) to get that environment variable in PS.

The next trick is realizing there is only one argument provided to RunDLL32, and that argument has arguments. So we need to enclose all the parts of the argument into one argument using quotes. But we need to keep the existing quotes in that argument, so we escape them with `.

Hope that helps...

Ƭᴇcʜιᴇ007

Posted 2012-01-23T20:07:58.800

Reputation: 103 763

Works like a charm, thanks! Any idea what "||fc9407e9`" means? Is it just some random application id? Ideally I'd like to apply this script to multiple computers but if the string is different on every computer... – payling – 2012-01-24T13:12:53.913