Installation

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Installation

#16 Post by foxidrive » 01 Apr 2013 20:21

Zip archives keep the files inside them when they are extracted. So the files will remain inside the ZIP archive once they are extracted to a folder, they aren't moved.

Do you want to check if an archive has been extracted to a folder?
That could be done by checking if a known file exists in the folder.

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Installation

#17 Post by MLGsuperGame414 » 02 Apr 2013 04:54

Could we have it extract an archive into a folder that it makes, then delete the archive?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Installation

#18 Post by foxidrive » 02 Apr 2013 05:44

Yes. This will create the folder on the desktop,

md "%userprofile%\desktop\test folder"

Use the same path in the Winrar command to extract the archive to "%userprofile%\desktop\test folder"

Then use the del command to delete the "archive.zip"

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Installation

#19 Post by MLGsuperGame414 » 03 Apr 2013 19:50

Okay now I would like to add a status so the user can see whats happeneing.

Creating Extraction folder...

Is there any way to check if a folder with a given name is in a Dir?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Installation

#20 Post by foxidrive » 03 Apr 2013 23:27

MLGsuperGame414 wrote:Okay now I would like to add a status so the user can see whats happeneing.

Creating Extraction folder...


Use the echo command.

Is there any way to check if a folder with a given name is in a Dir?


if exist "d:\dir\folder\" echo folder exists

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Installation

#21 Post by MLGsuperGame414 » 04 Apr 2013 05:07

Can we use else in batch? So if its not there we can let the user know its not there?

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Installation

#22 Post by Squashman » 04 Apr 2013 06:11

MLGsuperGame414 wrote:Can we use else in batch? So if its not there we can let the user know its not there?

Could you at least attempt to do a little research before asking all these questions. If you would read the help file for a lot of these commands you could probably figure it out on your own or at least search the web for the answer.

Open up a command prompt and type IF /?

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Installation

#23 Post by MLGsuperGame414 » 04 Apr 2013 19:45

Well I did read that and didnt understand but if you want my current code here it is.

Code: Select all

@echo off
set empty=Y
for /F %%G in ('dir /b C:\Users\Compklr\Desktop\not') do set empty=N

IF "%empty%"=="Y" (echo Directory is Empty) else echo Dir is not empty

pause

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Installation

#24 Post by foxidrive » 04 Apr 2013 23:43

With the /a-d it will only check for file and ignore folders inside the test folder.


Code: Select all

@echo off
set "empty=Y"
for /F %%G in ('dir /b /a-d C:\Users\Compklr\Desktop\not') do set "empty=N"

IF "%empty%"=="Y" (
echo Directory is Empty
) else (
echo Dir is not empty
)
pause

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Installation

#25 Post by MLGsuperGame414 » 14 Jul 2013 11:32

Sorry it took my so long to get back to this, it seems i'm having an issue with the syntax when using the move command here is my code.

Code: Select all

move /Y C:\Users\Compklr\Desktop test.txt C:\Users\Compklr\Desktop\CUsersCompklrDesktop
pause


I'm simply trying to move a text file from my desktop to a folder on my desktop.

I fixed it, I figured the error was the spaces

Code: Select all

move C:\Users\Compklr\Desktop\test.txt "c:\Program Files"
pause


Now I am denied access though, I'm on the Administrator account too.

Edit:
I then ran it as an administrator and it worked, I'm now curious is there any way around requiring to run as an administrator?
Last edited by MLGsuperGame414 on 14 Jul 2013 11:48, edited 2 times in total.

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Installation

#26 Post by penpen » 14 Jul 2013 11:45

I assume there is missing a backslash prior to test.txt.

penpen

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Installation

#27 Post by MLGsuperGame414 » 14 Jul 2013 13:06

Alrighty my last problem is this

Code: Select all

@echo off
CLS
move C:\Users\%USERNAME%\Desktop\test.txt "C:\Users\%USERNAME%\Program Files"
set empty=Y
for /F %%G in ('dir /b C:\Program Files\test.txt') do set empty=N
If "%empty%"=="N" echo File is there
if "%empty%"=="Y" echo File is not there
Pause


I moving a file from my desktop to program files, yet I cant get my file to let the user know whether or not the file is now in the program files dir, or not. It always just says its not there.

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Installation

#28 Post by penpen » 14 Jul 2013 14:42

MLGsuperGame414 wrote:Edit:
I then ran it as an administrator and it worked, I'm now curious is there any way around requiring to run as an administrator?
Obviously not.

MLGsuperGame414 wrote:

Code: Select all

@echo off
CLS
move C:\Users\%USERNAME%\Desktop\test.txt "C:\Users\%USERNAME%\Program Files"
set empty=Y
for /F %%G in ('dir /b C:\Program Files\test.txt') do set empty=N
If "%empty%"=="N" echo File is there
if "%empty%"=="Y" echo File is not there
Pause


I moving a file from my desktop to program files, yet I cant get my file to let the user know whether or not the file is now in the program files dir, or not. It always just says its not there.
I assume you are using the wrong directory, either when using the move command, or within the for loop.

penpen

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Installation

#29 Post by foxidrive » 14 Jul 2013 18:20

MLGsuperGame414 wrote:Alrighty my last problem is this

Code: Select all

@echo off
CLS
move C:\Users\%USERNAME%\Desktop\test.txt "C:\Users\%USERNAME%\Program Files"
set empty=Y
for /F %%G in ('dir /b C:\Program Files\test.txt') do set empty=N
If "%empty%"=="N" echo File is there
if "%empty%"=="Y" echo File is not there
Pause


I moving a file from my desktop to program files, yet I cant get my file to let the user know whether or not the file is now in the program files dir, or not. It always just says its not there.


Replace this

Code: Select all

set empty=Y
for /F %%G in ('dir /b C:\Program Files\test.txt') do set empty=N
If "%empty%"=="N" echo File is there
if "%empty%"=="Y" echo File is not there
Pause


with this:

Code: Select all

if exist "C:\Program Files\test.txt" (echo File is there) else (echo File is not there)
Pause


c:\program files is a restricted location in modern windows - pick somewhere else.

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Installation

#30 Post by MLGsuperGame414 » 14 Jul 2013 21:43

Would any dir in Program Files work?

Post Reply