Hi
I have an automation batch script that calls diskpart and does things to disks. I need the script to pass success or error codes on end but cannot work out how to do it.
An example would be that im trying to expand a disk using diskpart but there is no space available to do this. I get a message stating that there is not available space, but it does not give me an error code. Or if it is, im not reading it correctly.
Any help would be greatly appreciated here.
Thanks
R
How do i get error code from diskpart in batch file?
Moderator: DosItHelp
Re: How do i get error code from diskpart in batch file?
I realize you have code in your other post but you should still post all relevant code in all your questions so people do not have to search and destroy for what you are trying to do.
Re: How do i get error code from diskpart in batch file?
Silly me. I was supposed to add this
Code: Select all
setlocal EnableDelayedExpansion
set tempfile="c:\windows\temp\diskpart_create_tmp.txt"
set listfile="C:\windows\temp\diskpark_listdisks_tmp.txt"
set otherfile="C:\windows\temp\diskpart_listdisks_output.txt"
ECHO list volume >!listfile!
echo off
diskpart /s !listfile! > !otherfile!
for /F "skip=8 tokens=2-6" %%a in (C:\windows\temp\diskpart_listdisks_output.txt) do (
@echo %%a %%b %%c
@if /I "%%b" == "%1" (
echo Extend %%b
echo select volume %%a >!tempfile!
echo extend >>!tempfile!
diskpart /S !tempfile!
)
)
del !tempfile!
del !listfile!
del !otherfile!
-
- Posts: 240
- Joined: 04 Mar 2014 11:14
- Location: germany
Re: How do i get error code from diskpart in batch file?
The issue is: the list is not subdivided properly.
If the Volumename is 2-part the allocation becomes wrong. instead, you must read in the whole line and assign this into a variable - then must be subdivided in the suitable offset. With the help of these limbs you can process the mistake after a condition.
Phil
If the Volumename is 2-part the allocation becomes wrong. instead, you must read in the whole line and assign this into a variable - then must be subdivided in the suitable offset. With the help of these limbs you can process the mistake after a condition.
Phil
Re: How do i get error code from diskpart in batch file?
Phil
Thanks for responding, but im not 100% sure what you mean. Unfortunately, im not a native Batch scripter.
Thanks
Rusty
Thanks for responding, but im not 100% sure what you mean. Unfortunately, im not a native Batch scripter.
Thanks
Rusty
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: How do i get error code from diskpart in batch file?
rusty_uk wrote:Phil
Thanks for responding, but im not 100% sure what you mean. Unfortunately, im not a native Batch scripter.
Thanks
Rusty
Spaces in file names break everything; avoid them at all costs.