diskpart "myScript.txt":
select disk 1
convert dynamic noerr
select disk 2
convert dynamic noerr
create volume stripe disk=1,2 noerr
assign letter=X noerr
.
.
When running from the command prompt: diskpart /s myScript.txt
it works as expected.
However, when run using win api's CreateProcess()
both the convert commands do work but when it gets to
create volume
, it displays:
"The arguments you specified for this command are not valid"
. .
Now, to make things more interesting:
If the script is executed again from CreateProcess() a 2nd time (given the disks are now converted and it gives a correct error for the convert comamnds),
when it gets to the create volume
, it does work.
This makes me think it has something do with the disks and or executable?
Any point in the right direction is appreciated as this is very confusing. Thanks.
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
strncpy( command, "diskpart.exe /s myScript.txt", (sizeof(command) - 1) );
CreateProcess( "c:\\WINDOWS\\system32\\diskpart.exe",
command,
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi ) );
end original question________________________________________________________
EDIT:
Updates and more info:
Added about 15 - 20 seconds worth of delay before create volume command, still got the same error message.
Also, split the work into two scripts, with two calls to CreateProcess(). On the second script, just calling "create volume" and assign, it hung for a while and then came back with a "this command cannot be completed at this time"..or something to the effect.
Another thing to note: On the first script, putting them into dynamic, it was running about twice as slow compared to running with command prompt.
Maybe should just run the whole thing twice (with errors on the second run) as that did work
EDIT2
The 2 scripts is now working, or worked when I tried it again. Not sure why it didn't work the first time.