Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, im trying to make a batch file that i can run at startup, that will install any exe file the a folder, then never run it again. the best i can come up with is bellow, the main problem is the exes have to be named the same, is it possible to use the dir /b command to make a list of the exes in the folder, then save that list as a log, and run the exes that havent been run?
In the end, i would like to be able to stick any exe in the package folder, and have the pc running this batch to run it ONCE only.
@echo off
set A=packageaif exist \\server\package\%A%.txt goto SkipA
\\server\package\%A%.exe
echo Installed > %dir%\%A%.txt
:SkipA

Hi Madian
You could try renaming your .txt and .exe files to the current date and ruuning the batch file below using your own directories.
the xdir.exe is a c-program I wrote to display a directory like the old msdos used to ie: Filenames first. This creates a date variable of
dd-mm-yy I could change this to display a another date format if required.
or even have a time variable if needed. Send an email if this will help you.@echo off
rem Sets DATE environment varable
echo @echo off > abc123.bat
echo set date=%%2>> abc123.bat
xdir.exe abc123.bat > abc1234.bat
call abc1234.bat
del abc123.bat > nul
del abc1234.bat > nulset a=%date%.exe
if exist %a% goto Skip
call %a%
echo Installed %a%
:Skip

Hello, Madlan.
This should do it:
@echo off
if "%1"=="GoTo" goto %2
set DIR=\\local
set LIST=packagelist
for %%? in (\\server\package\*.exe) do call %0 GoTo process %%?
for %%? in (DIR LIST) do set %%?=
goto eof
:process
FIND "%3" < %DIR%.\%LIST%.TXT > nul
if not errorlevel=1 goto eof
call %3
echo %3>> %DIR%.\%LIST%.TXT
:eofSo, %DIR% carries the local folder, and %LIST% the list name. Is that what you needed?
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br____________________________________________________

if "%1"=="GoTo" goto %2
set DIR=C:\packages
set LIST=\\MANLAND-S1\packages\packages
for %%? in (\\MANLAND-S1\packages\*.exe) do call %0 GoTo process %%?
for %%? in (DIR LIST) do set %%?=
goto eof
:process
FIND "%3" > %DIR.%\%LIST%.TXT
:eofThis is the script with the details entered, The output is:
FIND "\\MANLAND-S1\packages\TEST.exe"
C:\packages\\\MANDLAND-S1\packages\packages.txt
Path not found
whats wrong?

Sorry, my fault works fine!
can it be made to run ONCE each time the batch file is run?
eg, if i put two exes in the packages folder, it will run both of them, can it be modified to run one, then the other next time it restarts?

First thing, let's get these directories straigt. You have a shared directory which the executable files, which is
\\MANLAND-S1\packages
And you have a local directory, which is
C:\Packages
Is that right? And then, the list with the executable files which were already run should be stored on a .txt file under that local directory, like the file
C:\Packages\packlist.txt
Is that all right? Now, this new batch script below will look for a .exe file on the folder %SERVER% which is not listed on the file %LIST%. Once it finds a .exe file not listed, it will execute it, add it to the list and exit.
===== BATCH SCRIPT BEGIN =====
@echo off
if "%1"=="GoTo" goto %2
%comspec% /e:4096 /c %0 GoTo start
goto eof
:startset SERVER=\\MANLAND-S1\packages
set LIST=C:\Packages\packlist.txtfor %%? in (%SERVER%.\*.exe) do call %0 GoTo process %%?
goto eof
:process
FIND "%3" < %LIST% > nul
if not errorlevel=1 goto eof
call %3
echo %3>> %LIST%
exit
:eof
===== BATCH SCRIPT END =====It's better to copy-paste the script, instead of looking and typing it again.
Does it work now? Pay attention to the directory variables - there are now only two.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br____________________________________________________

Hey, take it easy, man... hehe
You're welcome. Glad to help!
-- Leonardo PIgnataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

BTW, in response to your last email, the script from response #5 will only execute one .exe file, as I said before and as you requested.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

Im trying to use the VBS script from the bellow post,
I need the bellow Script to pass on a varible to a batch file called install.batIt needs to ask "whats the server/shared folder name"
and also "Whats the name of this PC"
*(unless theres a way to get the name of the pc?)*The Batch file is posted bellow also.
-------------
Dim usrName
usrName = Inputbox("Enter User Name","Enter Name")Set WShell = CreateObject("WScript.Shell")
WShell.Run "c:\accpac.bat " & usrName------------------
http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20382358.html>>>>>>>>>>>>>install.bat>>>>>>>>>>>>>>>>>>>>>>>
@echo off
if "%1"=="GoTo" goto %2
%comspec% /e:4096 /c %0 GoTo start
goto eof
:start
:: These are the two lines i need to take the
:: varibles passed on from the VBS script...
set SERVER=\\server\packages
set LIST=\\server\installlogs\pc1.txtfor %%? in (%SERVER%.\*.exe) do call %0 GoTo process %%?
goto eof
:process
FIND "%3" nul
if not errorlevel=1 goto eof
call %3
echo %3>> %LIST%
exit
:eof

I'll continue this discussion via email.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |