joefrench
Active Member
- Joined
- Oct 4, 2006
- Messages
- 357
I have some Script (a .bat file) that, when run in the directory that it exists in, will delete all "old versions" of files (i.e.- the program creating the files {ProEngineer}, on each save, creates a new "version" of the file with a .1,.2,.3,.4,etc... appended to the end of it).
The script in the file is as follows:
Currently, I am doing this by manually copying the purge.bat file to the directory that I want purged and double clicking it. Or by using an added right click action in Windows Explorer "C:\WINDOWS\system32\cmd.exe /c cd %1 &"C:\Program Files\proeWildfire 3.0\bin\purge.bat" *"
I would like to run this .bat file (as well as perform many other actions) from Excel VBA to purge directories based off of a value in Excel. I have tried to use VBA to copy the existing purge.bat file into the directory and run it through the shell command but this does not seem to work.
Note: I do not know much about the script except for what it does and that it was installed with the program (ProE).
I had been advised in a previous post http://www.mrexcel.com/board2/viewtopic.php?t=262396 to code the BAT file to accept a parameter and use %1 in the BAT file to do something with the passed string such as a subfolder but I am not sure how this would be done.
Would it be possible to re-write the script through VBA code and execute it?
The script in the file is as follows:
Code:
@echo off
Set MC = unset
if "%PROCESSOR%" == "INTEL_64" set MC=ia64_nt
if "%PROCESSOR%" == "INTEL_486" set MC=i486_nt
if "%PROCESSOR%" == "MIPS_R4000" set MC=r4000_nt
if "%PROCESSOR%" == "Alpha_AXP" set MC=alpha_nt
if "%PROCESSOR_ARCHITECTURE%" == "IA64" set MC=ia64_nt
if "%PROCESSOR_ARCHITECTURE%" == "x86" set MC=i486_nt
if "%PROCESSOR_ARCHITECTURE%" == "MIPS" set MC=r4000_nt
if "%PROCESSOR_ARCHITECTURE%" == "ALPHA" set MC=alpha_nt
if not "%winbootdir%" == "" set mc=i486_win95
if not "%MC%" == "unset" goto mc_done
echo ERROR Cannot detect what machine type you have.
echo Please make one of the following settings:
echo.
echo set PROCESSOR=Alpha_AXP - For Windows NT Alpha based machines.
echo.
echo set PROCESSOR=MIPS_R4000 - For Windows NT MIPS based machines.
echo.
echo set PROCESSOR=INTEL_486 - For Windows NT Intel based machines.
echo.
echo set PROCESSOR=INTEL_64 - For Windows Intel Itanium based machines.
echo.
echo set winbootdir=<boot dir> - For Windows 95/98 machines.
echo.
exit
: mc_done
if NOT "%mc%" == "i486_win95" goto postenv4096
if "%env4096%" == "true" goto postenv4096
Set env4096 = True
command.com /E:4096 /C %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
set env4096=
GoTo ptc_end
: postenv4096
set PRO_MACHINE_TYPE=%MC%
if "%PROOBJ_START_DIRECTORY%" == "" set PRO_DIRECTORY=
if NOT "%PRO_DIRECTORY%" == "" "%PRO_DIRECTORY%\bin\%MC%_ptc_setvars" %0 "purge" bat
if "%PRO_DIRECTORY%" == "" %MC%_ptc_setvars %0 "purge" bat
Call ptc_setvars.bat
del ptc_setvars.bat
if NOT "%mc%" == "i486_win95" set start_cmd=start ""
if "%mc%" == "i486_win95" set start_cmd=start
set PRO_DIRECTORY=%PRODIR%
if NOT "%PTCPATH%" == "" goto ptcpathset
if NOT "%mc%" == "i486_win95" goto not95
Set Path = "%PRO_DIRECTORY%\bin;%path%"
GoTo pathdone
: not95
set path=%PRO_DIRECTORY%\bin;%path%
: pathdone
Set PTCPATH = True
: ptcpathset
"%PRODIR%\%MC%\obj\purge.exe" %1 %2 %3 %4 %5
: ptc_end
I would like to run this .bat file (as well as perform many other actions) from Excel VBA to purge directories based off of a value in Excel. I have tried to use VBA to copy the existing purge.bat file into the directory and run it through the shell command but this does not seem to work.
Note: I do not know much about the script except for what it does and that it was installed with the program (ProE).
I had been advised in a previous post http://www.mrexcel.com/board2/viewtopic.php?t=262396 to code the BAT file to accept a parameter and use %1 in the BAT file to do something with the passed string such as a subfolder but I am not sure how this would be done.
Would it be possible to re-write the script through VBA code and execute it?