CMD Which section is active

Is there a way to find out in the CMD script which partition Windows is installed on? I need to make a program that makes a backup, but Windows is not always onC:\

I tried

C:\>DISKPART  
DISKPART>list volume



Volume      Bst  Bezeichnung   DS     Typ         Gr"áe    Status     Info
----------  ---  -----------   -----  ----------  -------  ---------  --------
Volume 1     C   XP_speziell   NTFS   Partition      9 GB  OK         Startpar
Volume 2     D   XP_allgemein  FAT32  Partition     28 GB  OK                 
Volume 3     E   DATEN         FAT32  Partition     28 GB  OK  

but I need this as one piece of code to make IF from it.

+4
source share
2 answers

echo %systemdrive%will give you the drive where Windows is installed. I'm not sure what you mean by “make IF from it,” but if you want to check if a given drive is an OS drive, you can do something like

if "%systemdrive%"=="C:" (
  [commands...]
)

, " " , . , , , .

+1

cd% windir%

, Windows ​​

+1

Source: https://habr.com/ru/post/1527478/


All Articles