Computing.Net > Forums > Disk Operating System > Batch help: dir /b and >

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch help: dir /b and >

Reply to Message Icon

Name: madlan
Date: January 29, 2003 at 12:13:15 Pacific
OS: 98SE
CPU/Ram: 2.5G p4 512MB
Comment:

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=packagea

if exist \\server\package\%A%.txt goto SkipA
\\server\package\%A%.exe
echo Installed > %dir%\%A%.txt
:SkipA



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: January 29, 2003 at 17:22:13 Pacific
Reply:

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 > nul

set a=%date%.exe

if exist %a% goto Skip
call %a%
echo Installed %a%
:Skip



0

Response Number 2
Name: Secret_Doom
Date: January 29, 2003 at 22:57:15 Pacific
Reply:

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
:eof

So, %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

____________________________________________________


0

Response Number 3
Name: madlan
Date: January 30, 2003 at 03:46:02 Pacific
Reply:


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
:eof

This 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?



0

Response Number 4
Name: madlan
Date: January 30, 2003 at 06:50:23 Pacific
Reply:

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?


0

Response Number 5
Name: Secret_Doom
Date: January 30, 2003 at 10:38:50 Pacific
Reply:

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
:start

set SERVER=\\MANLAND-S1\packages
set LIST=C:\Packages\packlist.txt

for %%? 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

____________________________________________________


0

Related Posts

See More



Response Number 6
Name: madlan
Date: January 30, 2003 at 17:35:14 Pacific
Reply:

My mistake it does do it! thankyou soo much! perfect! you ARE the dos god!


0

Response Number 7
Name: Secret_Doom
Date: January 30, 2003 at 19:59:30 Pacific
Reply:

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


0

Response Number 8
Name: Secret_Doom
Date: January 30, 2003 at 20:01:34 Pacific
Reply:

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


0

Response Number 9
Name: madlan
Date: January 31, 2003 at 04:16:06 Pacific
Reply:

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.bat

It 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.txt

for %%? 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


0

Response Number 10
Name: Secret_Doom
Date: January 31, 2003 at 08:35:19 Pacific
Reply:

I'll continue this discussion via email.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Batch help: dir /b and >

Need help to shutdown and view PCs. www.computing.net/answers/dos/need-help-to-shutdown-and-view-pcs/16727.html

BATCH HELP: Copy files with rename! www.computing.net/answers/dos/batch-help-copy-files-with-rename/16874.html

Simple batch help www.computing.net/answers/dos/simple-batch-help/17002.html