Questions tagged [diskpart]

15 questions
2
votes
1 answer

How to use PowerShell to detect unallocated space on a MBR disk?

I am currently facing an issue with one of my MBR disks on a Windows server. The disk is supposed to have a maximum size of 2048GB, but I have noticed that there is additional space allocated to it from the storage end. After checking the disk, I…
Fajela Tajkiya
  • 629
  • 2
  • 10
1
vote
1 answer

Running diskpart in the same window from where it is called

Calling diskpart.exe opens it in a new legacy terminal windows. I want to run diskpart.exe within the same terminal window where it was called from. How can I do that?
Melvin Calvin
  • 143
  • 10
1
vote
0 answers

How to mount a VHD with only one partition?

I'm developing a project and I need the code in C# to assemble a vhd, and assign a letter to it. During the process of creating the vhd, I managed to do it via cmd by diskpart, but at that time I didn't assign a letter to it because the intention is…
Tomás
  • 33
  • 1
  • 6
1
vote
2 answers

How do I use RedirectStandardInput when running a Process with administrator privileges in C#?

I'm trying to run a process using diskpart, but to do that I need administrator privileges because I'm using a PC at my work. In order to run a Process as administrator I need Process.StartInfo.Verb = "runas" and I also need…
0
votes
0 answers

Volume doesn´t show up in Windows after diskpart

I use a diskpart script for my backup application in WinPE. It cleans the data drive (disk 1) and adds a partition to it so the image can be applied later. The script I wrote: select disk 1 rem wiping disk ... clean rem == Data partition…
0
votes
1 answer

C# Check if pendrive is read-only and run DISKPART to change readonly status

I'm quite lost with this task. Basically I have to check if a pendrive has readonly property. If it's protected I have to unprotect it (we use DISKPART.exe), update some files, then protect it again. If it's not protected, I just have to update…
0
votes
0 answers

i am trying to delete ext4.vhdx in Docker wsl file

"DISKPART> attach vdisk readonly Virtual Disk Service error: The virtual disk is already attached." it is not turning disk into readonly. i tried diskpart commands but its throwing some error.
0
votes
0 answers

diskpart didn't work in unattended sysprep

I run sysprep with an answer file, which runs a batch script in the specialize configuration pass. The batch script gets the target HDD index, and runs diskpart against that HDD. All files are located in C:\temp: C:\temp\unattend.xml …
0
votes
1 answer

Diskpart batch file with user input selecting disk and partition number

I am trying to creating batch file. How to use user input in selecting partition no? I want to format some partitions only using diskpart. I already learn how to select disk number but I want to learn select partition number also. Sometimes…
0
votes
0 answers

Drive on, Backup, Drive offline via batch file

I try to write a batch file which: Set one drive online Backup files Set drive back offline I have a batch file that sets the drive online, one file taking it offline and a batch file that robocopys the files I want. BUT I dont get them together.…
Joeykenoy
  • 3
  • 3
0
votes
0 answers

Listing virtual disks in Java

Is there a way to list all virtual disks attached using Java? I've tried using ProccessBuilder to open diskpart and running command and then using InputStreamReader, save lines into an array to later extract vhd name. But after running diskpart…
Maczosss
  • 23
  • 5
0
votes
1 answer

Can diskpart take command line parameters? Or can I fake them with powershell?

I understand I can use diskpart /s to script diskpart select vdisk file=FILE_SUPPLIED_BY_COMMAND_LIME_PARAMETER attach vdisk readonly compact vdisk detach vdisk exit And then run it with: diskpart /s scriptname.txt /t 15 But can I add command lime…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
-1
votes
1 answer

How is it possible to allow a normal windows user to launch a program e.g. diskpart.exe that requires admin rights without prompting

I want to call diskpart.exe from my application (C# .net 4.8) to delete and reinitialize an attached storage device. However, the user needs administration rights to do this. However, I do not want to store an admin user with password in the…
-1
votes
1 answer

Recover data deleted by diskpart

After accidentally deleting all data on my disk using "clean" on diskpart, my HDD is now empty. I've searched and used some recovery data apps, one of them is EaseUS. After scanning hours, it shows up exactly all data I lost but requiring fee to…
hhhhh
  • 33
  • 5