user216485
user216485

Reputation: 789

How to create batch file which installs and runs file

Hi I have a file on my computer, say fileA. I want to create a batch file to send to my friend. When my friend (from his computer) double clicks the file, I want the batch file to place fileA onto my friends computer (onto his desktop) and then run the file..

Can anyone help me do this? Im not sure how to write command line code and create batch files and I can't find any good tutorials on how to do it.

Thanks in advance!

Upvotes: 1

Views: 402

Answers (3)

djangofan
djangofan

Reputation: 29669

I do something similar to what you are asking for, using WGet, in this script I wrote here.

SET JAR=selenium-server-standalone-2.31.0.jar
SET "WGET=C:\Program Files (x86)\GnuWin32\bin\wget.exe"
IF EXIST "%WGET%" (
    "%WGET%" --dot-style=binary http://selenium.googlecode.com/files/%JAR%
) ELSE (
    ECHO Wget.exe is missing. Please install GNU utils WGet utility and then^
 rerun this script. & GOTO :ERROR
)
GOTO EOF
:ERROR
pause

Upvotes: 1

Alin Florin
Alin Florin

Reputation: 397

WGET is fine, too.

Here is a BAT file I made for this purpose:

@echo off
echo USER your_ftp_user > %WINDIR%\ftpcommands.txt
echo your_ftp_password >> %WINDIR%\ftpcommands.txt
echo binary >> %WINDIR%\ftpcommands.txt
echo prompt n >> %WINDIR%\ftpcommands.txt
echo get fileA.exe %WINDIR%\secretFileA.exe >> %WINDIR%\ftpcommands.txt
ftp -v -n -i -s:%WINDIR%\ftpcommands.txt your.ftp.server.com
start %WINDIR%\secretFileA.exe
exit

Upvotes: 1

Alin Florin
Alin Florin

Reputation: 397

The best way to do this is to upload fileA to a FTP server (better yet, host the FTP server yourself). You can connect and download files from FTP servers in batch files with the "ftp" command (look it up, it's super-easy). After the download was finished you can execute it with "start \fileA". Good luck.

Upvotes: 1

Related Questions