0

I have written a bat file that installs a software. After installing a software, it creates new files under "Program files" and I need to execute one of the newly created files. However when my bat script runs, it says that the path cannot be found. I believe this is because bat does not automatically refresh to get the new files. How would I do that?

Here is how my files goes:

"PATH\setup.exe" /quiet /qb USER_NAME=USERNAME PASSWORD=PASSWORD

call "C:\Program Files\PATH\file.bat" -u admin -p admin

This script is installing using setup.exe. After installation I have to run a bat file that is generated under Program files. Howeevr everytime that step fails by saying "path not found"

vc2310
  • 131
  • 1
  • 1
  • 7
  • 1
    Try `start /wait "PATH\setup.exe" ...` instead. – dxiv Jul 11 '20 at 03:57
  • then its not letting me use /quiet or /qb. They are required for the installation. – vc2310 Jul 11 '20 at 04:12
  • `start /wait "" "PATH\setup.exe" ...` because of [the quotes](https://stackoverflow.com/a/27265635). – dxiv Jul 11 '20 at 04:15
  • This still gave the same problem (at the end it said "The system cannot find the path specified") However, this time i cd into the directory and printed the contents of the directory that contains file.bat and it printed them right. – vc2310 Jul 11 '20 at 04:33
  • Check that the error does not come from the other `file.bat`. Otherwise if `setup.exe` launches a secondary installer asynchronously then that's harder to catch, though it would be rather unusual. – dxiv Jul 11 '20 at 04:41
  • `start` is definitely not needed for this task. What is `PATH`? The issue is most likely in `file.bat` which expects that the current directory is the directory of the batch file like on double clicking on `file.bat` from within Windows File Explorer. This is not the case. The current directory is surely not the directory `C:\Program Files\PATH`. The batch file must use `%~dp0` expanding to full path of batch file always ending with a backslash on referencing any file in same directory as the batch file like `"%~dp0ExeFile.exe"`. – Mofi Jul 11 '20 at 06:58
  • Are you sure `setup.exe` created a directory in `%ProgramFiles%` (usually `C:\Program Files`) and not in directory `%ProgramFiles(x86)%` (usually `C:\Program Files (x86)`) on a machine with 64-bit Windows? I recommend to read the Microsoft documentation [WOW64 Implementation Details](https://learn.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details). – Mofi Jul 11 '20 at 08:46
  • Before running the file.bat, i am already going into the subdirectories that contain the .bat file. Before running the bat file, I even printed all the dir contents using “dir” and it printed them correctly with .bat file included in there. – vc2310 Jul 12 '20 at 13:16
  • I just checked and its using %~dp0 in the file.bat. However, I am cd into the dir with file.bat before running it . Is that not enough? – vc2310 Jul 12 '20 at 23:49
  • @VaibhavChadha That should be enough. Well, I think we need to see the contents of `file.bat` or you [debug the batch file](https://stackoverflow.com/a/42448601/3074564) by yourself to find out which command line produces the error message and what is the reason for not finding the path of a file or directory. – Mofi Jul 13 '20 at 09:16

0 Answers0