I'm trying to initialize the Windows Sandbox programatically.
My objective is to generate a .wsb
config file and then start it.
Currently I am using Process.Start()
method, but I keep getting an error on the Start()
method.
This is the code:
var sbProc = new Process();
sbProc.StartInfo.FileName = configPath;
sbProc.Start();
sbProc.WaitForExit();
Throws: System.ComponentModel.Win32Exception: 'Application not found'
.
I am sure the file exists as I have tried opening it by double-click and through the Command Line. Both worked like expected, so I'm assuming it is referring to the associated application (in this case Windows Sandbox).
I have tried adding:
sbProc.StartInfo.UseShellExecute = false;
Throws: System.ComponentModel.Win32Exception: 'The specified executable is not a valid application for this OS platform.'
.
It's the same exception but a different message, which is actually very confusing. As said above, I am 100% sure my OS supports this feature; every requirement is supported and enabled.
Is it possible that Process.Start()
can't handle .wsb
files and if so, how could I achieve what I am looking for?
I'm open for any suggestions and thanks in advance!
UPDATE:
I have tried changing the verb to Invoke
and Start
with the following code:
sbProc.StartInfo.Verb = "Start";
and
sbProc.StartInfo.Verb = "Invoke";
Throws:System.ComponentModel.Win32Exception: 'No application is associated with the specified file for this operation'
How can I associate and application with the file?