Page 1 of 1
create vhd disk file
Posted: 16 Jul 2014 23:40
by yusef88
DiskPart
create vdisk file="C:\vdisks\disk1.vhd" maximum=16000
attach vdisk
create partition primary
assign letter=g
format
===========
can xy scripts ask me to choose these colored values?
Re: create vhd disk file
Posted: 16 Jul 2014 23:47
by highend
input() is your friend.
Re: create vhd disk file
Posted: 16 Jul 2014 23:56
by yusef88
thanks but how?
i can use it for one variable..what about multi variables
Code: Select all
$a = input("ShutDown Timer", "1h=3600);run "cmd /k ""Shutdown -r -f -t $a&exit"""
Re: create vhd disk file
Posted: 16 Jul 2014 23:58
by highend
By using a divider if you want to use only one input for all three values.
E.g.:
Code: Select all
$delim = "|";
$vhdScriptName = "%temp%\~vhdScript.txt";
$values = input("Input values...", "The delimiter is: " . $delim . "<crlf>1.) .vhd file name<crlf>2.) maximum<crlf>3. drive letter", "C:\vdisks\disk1.vhd|16000|g", , , 600, 200);
$vhdFile = gettoken($values, 1, $delim);
$vhdFolder = getpathcomponent($vhdFile, "path");
$maximum = gettoken($values, 2, $delim);
$driveLetter = gettoken($values, 3, $delim);
if (exists($vhdFolder) == 0) { new($vhdFolder, "dir"); }
$vhdScriptContent = <<<>>>
create vdisk file="$vhdFile" maximum=$maximum
attach vdisk
create partition primary
assign letter=$driveLetter
format
>>>;
writefile($vhdScriptName, $vhdScriptContent);
run """DISKPART"" /s ""$vhdScriptName""", , 2, 1;
delete 0, 0, $vhdScriptName;
Untested but it should work.
Ofc you have to start it from an elevated XY (or use a vbscript that autoelevates it)...
Re: create vhd disk file
Posted: 17 Jul 2014 01:06
by yusef88
i didn't test it yet...many thanks Mr highend
Re: create vhd disk file
Posted: 18 Jul 2014 01:44
by yusef88
doesn't work, it create a bat file in temp folder but no cmd window pops up, even running it manually does nothing
Re: create vhd disk file
Posted: 18 Jul 2014 08:10
by highend
?
You aren't using my script (it doesn't create a .bat file at all, only a .txt one)...
Re: create vhd disk file
Posted: 18 Jul 2014 22:08
by yusef88
OK i tested the script again, doesn't work for me
Re: create vhd disk file
Posted: 18 Jul 2014 22:35
by highend
It works for me...
1. You executed it from an ELEVATED XY instance?
2. The folder of the .vhd file was created?
What happens when you execute
diskpart /s <path to a .txt file, that contains the content of $vhdScriptContent (with resolved variable names)>
from a command prompt?
Re: create vhd disk file
Posted: 18 Jul 2014 22:45
by yusef88
highend

very sorry i did some mistakes>>> works fine now..many thanks.