Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HOW TO AUTOMATE DISKPART USING A BATCH FILE
#1
Hello Brian and Administrators

I am trying to run DISKPART from a batch file to save keying in all the commands every time I want to make a USB stick bootable!

Although there seem to be numerous solutions on the Internet I have yet to find one which works.
I am running the latest version of Windows 10 PRO.

I would like to open a command prompt, with administrator rights, to enter the following sequence of commands (without numbers 1 to 9):-

1.  diskpart
2.  list disk
3.  select disk
4.  clean
5.  create partition primary
6.  select partition 1
7.  active
8.  format fs=fat32 quick
9.  assign
Type EXIT and ENTER to finish

I also want to be able to enter "LIST DISK" and "SELECT DISK" with an input choice for the disk number.

I know you guys make "great videos" but as long as you can give me clear instructions, details could come just as coding!
Please specify any file(s) I need to produce.

Thank you for any assistance you can give!

Kind Regards
Mike-m5
Reply

#2
Mike-m5 you are double posting the same questions

you already have an open thread https://briteccomputers.co.uk/forum/showthread.php?tid=4131
Reply

#3
Credit goes to Even Greene Add the snippet code to the top of your batch file and it will run as administrator

Code:
@echo off


:: Get ADMIN Privs
:-------------------------------------
mkdir "%windir%\BatchGotAdmin"
if '%errorlevel%' == '0' (
  rmdir "%windir%\BatchGotAdmin" & goto gotAdmin 
) else ( goto UACPrompt )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute %0, "", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    pushd "%CD%"      
    CD /D "%~dp0"
:-------------------------------------
:: End Get ADMIN Privs

<YOUR BATCH SCRIPT HERE>
<left><form action="https://www.paypal.com/cgi-bin/webscr" method="post">If you are satisfied with my help, consider a donation. Thank you so much for your continued support! 
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="Y4ZDLXGFS4F8Q">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="0" height="0">
</form>

   </div></left> 
Reply

#4


<left><form action="https://www.paypal.com/cgi-bin/webscr" method="post">If you are satisfied with my help, consider a donation. Thank you so much for your continued support! 
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="Y4ZDLXGFS4F8Q">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="0" height="0">
</form>

   </div></left> 
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 Melroy van den Berg.