Download a .rar on mediafire with a bat File without Any Program - file

Hello i was trying to download a .rar archive on mediafire but it doesnt seem to work it the file doesnt get to the specific folder
"c:\potato"
Here is my code:
#Echo off
echo download press any key
pause
bitsadmin.exe /transfer "JobName"
http://download1142.mediafire.com/sxd533x3fosg/ymr5y2r0yax2fx8/minecraft+generator.zip C:\Potato.exe
pause

Try something like this:
#echo off
setlocal EnableDelayedExpansion
set "infile=http://download1142.mediafire.com/3b1mz9yb72tg/ymr5y2r0yax2fx8/minecraft+generator.zip"
set "outfile=Potato.zip"
cd "C:\"
echo download press any key
pause
powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('"%infile%"','"%outfile%"') | findstr "Exception error" >nul 2>nul
set "downloadComplete=%errorlevel%"
if %downloadComplete% neq 1 echo Something went wrong, please try again
if %downloadComplete% neq 1 pause
if %downloadComplete% neq 1 goto :eof
unzip "%outfile%" "minecraft generator.zip" >nul
unzip "minecraft generator.zip" "minecraft generator.exe" >nul
rename "minecraft generator.exe" "potato.exe"
pause
Please note that you used the mediafire URL instead of the actual file URL, and that you try to download a zip file to .exe. You should first download the file as zip, and then use unzip to unzip the files.
Also note that your second zip seems to be password protected.

Related

Windows 10 batch unzip multiple files with filename the same as zip directory name

I have about 60 files to unzip as you can see below:
I know the 7zip option, which can unzip all of them, but the problem is, that the file inside doesn't match the zip directory name, which would be highly desirable here.
I found some solutions for the batch file here:
https://superuser.com/questions/371384/extract-all-zips-in-a-directory-incl-subfolders-with-a-bat-file-or-dos-comm
and prepared some batch code for this which looks like this:
#echo off
setlocal
cd /d %~dp0
for %%a in (*.zip) do (
Call :UnZipFile "C:\my\Desktop current\Occ KMZ\bat\Aldebaran" "C:\my\Desktop current\Occ KMZ\bat\Aldebaran"
)
exit /b
but it doesn't work at all. I can neither unzip it nor get files.
The 7zip software has a few options, which potentially could be good
but I don't know how to use the 7Zip command line in order to get the unzipped file with the same name as the zip directory.
What should I do to automatize this section?
Here's something (minimal) that should work. Some parts can be done better (error handling and so on). It unzips each archive into a dir named like the archive but without the (.zip) extension.
script00.bat:
#echo off
setlocal enableextensions enabledelayedexpansion
set EXE_7Z="c:\Install\pc064\7Zip\7Zip\Version\7z.exe"
for %%g in ("%~dp0*.zip") do (
call :unpackFile "%%g"
)
goto :done
:unpackFile
set _ARCH_DIR="%~dp1%~n1"
rmdir /q /s %_ARCH_DIR% 2>nul
%EXE_7Z% x -o%_ARCH_DIR% %1 >nul 2>&1
goto :eof
:done
echo Done.
goto :eof
Output:
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow]> sopr.bat
### Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ###
[prompt]> tree /a /f q071380369
Folder PATH listing for volume SSD0-WORK
Volume serial number is 00000068 AE9E:72AC
E:\WORK\DEV\STACKOVERFLOW\Q071380369
file00.zip
file01.zip
script00.bat
No subfolders exist
[prompt]> q071380369\script00.bat
Done.
[prompt]> tree /a /f q071380369
Folder PATH listing for volume SSD0-WORK
Volume serial number is 0000006E AE9E:72AC
E:\WORK\DEV\STACKOVERFLOW\Q071380369
| file00.zip
| file01.zip
| script00.bat
|
+---file00
| kkt.py
|
\---file01
URLs.txt

Confirmation of FTP upload for user

I'm moving a task from manual to automatic
I'm well aware that you can't check for errors when doing this, but that's not my goal.
My code works as expected, but I'm missing... something
I need to let the user know that after I've put the file in the FTP location, that it was uploaded and they no longer need to wait for the file.
I've done this up to now by blagging the user, once the command has run, they just get told it's worked
#echo off
REM Generates the script
echo open 000.000.000.000> temp.txt
echo username>> temp.txt
echo password>> temp.txt
echo lcd "N:\line\line\line">> temp.txt
echo put file.txt>> temp.txt
echo quit>> temp.txt
REM Open FTP and run the script above
ftp -s:temp.txt
REM Remove the temp file
del temp.txt
REM Display confirmation
msg %username% "File sent to FTP"
Any help is greatly appreciated. I will add any more info if needed
You have to download the file back to see if it was correctly uploaded and do fc.
For unattened file download via ftp look at robvanderwoude's ftp. Don't forget that when saving the downloaded file it should have different name than the one you were uploading originally.
Then simply compare the files you have via fc command like this:
#echo off
fc c:\temp.txt r:\temp_to_check.txt > nul
if errorlevel 1 goto error
goto :EOF
:error
echo "The file was uploaded and downloaded incorrectly"
Answer specific to my question for visual purposes:
REM Open FTP and run the script above
ftp -s:temp.txt
REM File check
fc "N:\line\line\TEST.TXT" "N:\line\line\check_location\TEST.TXT" > nul
if errorlevel 1 goto error
REM Remove the temp file
del temp.txt
REM Display confirmation
msg %username% "File has now been sent to FTP"
goto :EOF
:error
msg "The file was uploaded or downloaded incorrectly"

Downloading file from URL using start chrome

I have a batch file that opens a URL to download a csv file, then I need to move and then rename that csv form downloads folder to other one.
What I have is:
#echo off
SET CCDIR=C:\Users\(username)\Desktop
SET LOADDIR=C:\Users\(username)\Downloads
ECHO ***************************************************************************
ECHO Downloading the file
ECHO ***************************************************************************
start chrome (URL string)
:NEXT
ECHO ***************************************************************************
ECHO Move CSV file from Downloads folder to Desktop
ECHO ***************************************************************************
move %LOADDIR%\*(file string)* %CCDIR%
ren %CCDIR%\*(file string)* (new file name)
I want to execute it all in the same bat, but just the start chrome is working, the bat is ignoring the move and ren.
How can I do that?
Based on my comment, you can give a try for this example to download a file with Certuil command
#echo off
Title Downloading a file using Certutil Command
Mode 70,5 & color 0A
SET CCDIR=%userprofile%\Desktop
SET LOADDIR=%userprofile%\Downloads
set "url=https://download.sysinternals.com/files/PSTools.zip"
echo(
ECHO ******************************************************************
ECHO Please wait a while ... Downloading the file ...
ECHO ******************************************************************
Call :download %url% %LOADDIR%
Rem Moving the downloaded file from the folder Downloads to Desktop
move /Y "%file%" "%CCDIR%\">nul
Rem Open the desktop folder with explorer
Explorer "%CCDIR%\"
goto :eof
::--------------------------------------------
:Download <Url> <File>
Set url="%~1"
Set file=%2\%~nx1
certutil.exe -urlcache -split -f %url% %file%>nul
Rem Deleting cache
certutil -urlcache "%~1" delete>nul
Rem Check referenced urlcache is deleted
certutil.exe -v -urlcache -split "%~1">nul
exit /b
::--------------------------------------------

check existing file in ftp batch file [duplicate]

I am writing a quick batch to see if a file exists after executing an exe.
The file is created with a YYYYmmDDnumbernumbernumber.xml file name according to the current date.
How do I check for the file with a variable in the beginning? Here is what I have so far:
#echo off
set mydate=%date:~10,4%%date:~4,2%%date:~7,2%
if not exist "ftp://FTPsite/%mydate%*.xml" (echo nah) else (echo yea)
pause
you cannot check existence of file on ftp server with IF.Instead try this after replacing the parameters that starts with MY_ :
!cls&echo off&setlocal ENABLEDELAYEDEXPANSION
!cls&goto :ftp_end
open MY_FTP_SERVER
user MY_USER
pass MY_PASS
cd MY_REMOTE_DIR
ls . local.file
bye
:ftp_end
ftp -s:%0
set mydate=%date:~10,4%%date:~4,2%%date:~7,2%
type local.file | findstr /B "%mydate%" | find ".xml" && echo FILE IS OUT THERE && goto :skip_file_is_not_there
echo FILE IS NOT THERE
:skip_file_is_not_there
del local.file /q >nul

Batch file leaves vbscript program open in Wordpad. Why?

My batch file contains a START command that runs a short vbscript program. When the batch file completes, the code of the vbscript program is shown in an open Wordpad window. This only started happening after we converted to Windows 7. Never happened under XP. Why does this happen and how can I prevent it? I have done extensive internet searching and come up with nothing.
Here is batch file:
#echo off
cls
echo.
echo Copying Latest Version of FREDS Database ...
echo.
xcopy "\\sstore02\S-Drive.OOD\OPI\FREDS\FREDS.mdb" "K:\FREDS\" /i /q /y
echo.
echo If you see "1 File(s) copied" then the copy was successful
echo.
echo Copying Shortcut Installer ...
echo.
xcopy "\\sstore02\S-Drive.OOD\OPI\FREDS\FREDS-Shortcut.vbs" "K:\FREDS\" /i /q /y
echo.
echo If you see "1 File(s) copied" then the copy was successful
echo.
echo Adding Shortcut icon to Desktop ...
echo.
Start K:\FREDS\FREDS-Shortcut.vbs
echo.
pause
You need to call cscript instat of start.
cscript /nologo K:\FREDS\FREDS-Shortcut.vbs
The option /noscript hides the version of cscript in the output.
Notepad is the registered program for the VBS extension on your machine.
Right click a VBS file and select Open With and then navigate to cscript.exe in c:\windows\system32 folder usually. Select the checkbox to always use that program and then the start command will work with VBS scripts and Cscript.

Resources