Win 10 works differently with this BAT file
Moderator: DosItHelp
-
- Posts: 5
- Joined: 17 Apr 2016 10:20
Win 10 works differently with this BAT file
This tutorial was made before Win 10 and needs some revising.
http://adhirmondal.com/how-to-add-or-re ... atch-file/
First of all it needs to be an CMD (admin) not a regular CMD. I went ahead and created a shortcut to CMD.EXE and put under advanced "run as administrator" and this works. I'm not sure how to get a BAT file to run this shortcut.
The diskpart script also doesn't work in Win 10
diskpart /s C:windowssystem32diskpart1.txt
Yet if I open CMD (admin) I can type
diskpart (ENTER)
list volume
select volume 5
assign letter=S (ENTER)
And this works. I'd like to be able to do this in a BAT file.
http://adhirmondal.com/how-to-add-or-re ... atch-file/
First of all it needs to be an CMD (admin) not a regular CMD. I went ahead and created a shortcut to CMD.EXE and put under advanced "run as administrator" and this works. I'm not sure how to get a BAT file to run this shortcut.
The diskpart script also doesn't work in Win 10
diskpart /s C:windowssystem32diskpart1.txt
Yet if I open CMD (admin) I can type
diskpart (ENTER)
list volume
select volume 5
assign letter=S (ENTER)
And this works. I'd like to be able to do this in a BAT file.
Re: Win 10 works differently with this BAT file
Gerry Peters wrote:The diskpart script also doesn't work in Win 10Code: Select all
diskpart /s C:windowssystem32diskpart1.txt
The path is broken, or it is a relative path.
To run as admin you may be able to use the runas command
-
- Posts: 5
- Joined: 17 Apr 2016 10:20
Re: Win 10 works differently with this BAT file
foxidrive wrote:Gerry Peters wrote:The diskpart script also doesn't work in Win 10Code: Select all
diskpart /s C:windowssystem32diskpart1.txt
The path is broken, or it is a relative path.
To run as admin you may be able to use the runas command
If you know how to fix the errors, please give me a BAT file example. With BAT files I'm a newbie at writing them. Thanks for your help
-
- Posts: 5
- Joined: 17 Apr 2016 10:20
Re: Win 10 works differently with this BAT file
I put your script in Notepad and named it diskpart.BAT
When I double clicked on it, I just got a blank CMD (admin) screen
I'm not sure if I'm supposed to put some text in this notepad file
diskpart-script.txt, if so let me know
And what temp folder do I put it in C:\temp?
Thanks,
When I double clicked on it, I just got a blank CMD (admin) screen
I'm not sure if I'm supposed to put some text in this notepad file
diskpart-script.txt, if so let me know
And what temp folder do I put it in C:\temp?
Thanks,
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Win 10 works differently with this BAT file
Running the script will automatically create and fill in diskpart-script.txt; you don't need to do anything.
%temp% is a system variable - again, you don't need to do anything.
Oh no, don't do that; if you do, the script will see the line where you call diskpart and just call the script again instead of running the program. Call it something else.
%temp% is a system variable - again, you don't need to do anything.
Gerry Peters wrote:I put your script in Notepad and named it diskpart.BAT
Oh no, don't do that; if you do, the script will see the line where you call diskpart and just call the script again instead of running the program. Call it something else.
-
- Posts: 5
- Joined: 17 Apr 2016 10:20
Re: Win 10 works differently with this BAT file
ShadowThief wrote:Running the script will automatically create and fill in diskpart-script.txt; you don't need to do anything.
%temp% is a system variable - again, you don't need to do anything.Gerry Peters wrote:I put your script in Notepad and named it diskpart.BAT
Oh no, don't do that; if you do, the script will see the line where you call diskpart and just call the script again instead of running the program. Call it something else.
Thanks ShadowThief. Ok this time I pasted the 11 line code that foxidrive posted in his last post. I saved it in a notepad file and named it GP test.BAT I double clicked on the Bat file and the CMD (admin) window opened, but it's totally blank - no text at all. Did you try this with Win 10 and get a different result?
Thanks,
Re: Win 10 works differently with this BAT file
I assume there are missing some "echoes" (untested):
penpen
Edit: remed out the line that looks strange.
Code: Select all
@echo off
(
rem echo diskpart
echo list volume
echo select volume 5
echo assign letter=S
)>"%temp%\diskpart-script.txt"
diskpart /s "%temp%\diskpart-script.txt"
del "%temp%\diskpart-script.txt" 2>nul
pause
penpen
Edit: remed out the line that looks strange.
Last edited by penpen on 21 Apr 2016 04:45, edited 1 time in total.
Re: Win 10 works differently with this BAT file
penpen wrote:I assume there are missing some "echoes" (untested):
penpen
![Image](https://t2.ftcdn.net/jpg/00/41/67/35/240_F_41673509_Gwz9Jrt43rdYtCtQmNBwyR0CNni58eQF.jpg)
Thank you penpen.
-
- Posts: 5
- Joined: 17 Apr 2016 10:20
Re: Win 10 works differently with this BAT file
Thanks penpen. I tried it by pasting your text into Notepad and saving it as a BAT file. When I run it, the CMD window opens but again no text. Can someone please try this and see if it works for them?
Thanks,
Thanks,
Re: Win 10 works differently with this BAT file
Gerry Peters wrote:Thanks penpen. I tried it by pasting your text into Notepad and saving it as a BAT file. When I run it, the CMD window opens but again no text.
Was there an S drive?
Was there no text at all on the screen?
Did you call it diskpart.bat ?
Re: Win 10 works differently with this BAT file
Gerry Peters wrote:Thanks penpen. I tried it by pasting your text into Notepad and saving it as a BAT file. When I run it, the CMD window opens but again no text.
Was there an S drive?
Was there no text at all on the screen?
Did you call it diskpart.bat ?
Just for giggles, save this script out the same way and call it mmm.bat
Code: Select all
@echo off
echo part 1
pause
Re: Win 10 works differently with this BAT file
I think, that you should not use the line "echo diskpart" (should be strange if there is a command that equals the executables name), i've remed out this line.
penpen
penpen