0

When I run the following query, the program opens but it is still asking for parameters instead of it taking the parameters from the start command. I am not running a batch file here, please correct my statement for errors.

START "TESTING" /D "D:\Work\ORMB DB Upgradation work\ORMB_DB_Upgrade_2.3.0.2.0_to_2.4.0.0.0\FW\FW42020\FW42020-HFix47\" /MIN /HIGH CDXPatch.exe "O" "schema_user" "schema_pass" "db_name" "Y"

The discussion so far have yielded the following command as best shot for solution:

echo.O&echo.user&echo.pass&echo.db&echo.Y | "Path\CDXPatch.exe" 

It yielded the following error:

enter image description here

  • 1
    Duplicate of http://stackoverflow.com/questions/26551/how-to-pass-command-line-parameters-to-a-batch-file – Techie Apr 09 '16 at 13:14
  • I am not running a batch file here. As I am new to batch scripting, it will be very helpful to me if you could correct the end of the posted statement where I provide the multiple parameters for the program. – Shivam Gupta Apr 09 '16 at 13:28
  • Your program probably cannot take parameters from the command line. Try `(echo.O&echo.schema_user&echo.schema_pass&echo.db_name&echo.Y) | CDXPatch.exe`. Put this inside a batch file, which you will then `START`. –  Apr 09 '16 at 14:03
  • I understand that you are trying to pass the output of string of echo commands to CDXPatch.exe but start command doesn't work that way. I have tried, the parameters were not passed to the program. – Shivam Gupta Apr 09 '16 at 14:13
  • I have tried, and they were. What program have you tried it with? I think your problem is that `CDXPatch.exe` ignores command line arguments and instead takes input only from the console. –  Apr 09 '16 at 14:18
  • The command looks OK, and an analogous command works fine on my machine. Does the command work as expected if you run it directly from the command line, i.e., without using `start` ? (Perhaps, for example, it doesn't like having quote marks around all the arguments?) – Harry Johnston Apr 09 '16 at 22:38

1 Answers1

0

Put this in your main batch file (replace CDXPatch.exe with CDXPatch.bat*):

START "TESTING" /D "D:\Work\ORMB DB Upgradation work\ORMB_DB_Upgrade_2.3.0.2.0_to_2.4.0.0.0\FW\FW42020\FW42020-HFix47\" /MIN /HIGH CDXPatch.bat "O" "schema_user" "schema_pass" "db_name" "Y"

Then put this into CDXPatch.bat (edited to support arbitrary number of arguments):

@(for %%a in (%*) do @echo.%%~a) | CDXPatch.exe

* CXDPatch.bat must be either in a directory specified in %PATH% or you must specify full path (eg. C:\User\CDXPatch.bat).

  • I can assure that I religiously followed what you told me but there was no response from the command prompt. The prompt just skipped over. I also checked the task manager but there was no CDXPatch.cmd that was shown as running. – Shivam Gupta Apr 10 '16 at 09:08
  • As @HarryJohnston commented on the question, I ran the CDXPatch.cmd without the start command. It gave me the following error: CDXPatch.exe unable to open the parameter file CDXPatch.par – Shivam Gupta Apr 10 '16 at 09:13
  • If there is a parameter file `CDXPatch.par` in the same folder as in `CDXPatch.exe`, maybe you can put your parameters in this file instead of passing them through command line. Also, what does it mean 'skipped over'? Have you checked if the program did what it was supposed to? By the way, `CDXPatch.cmd` does not show in the task manager, only `cmd.exe` and possibly `conhost.exe`. –  Apr 10 '16 at 10:37
  • Thanks a lot for such great info :) The program is supposed to update the database, it takes hours to do so. That's why I am pretty sure it didn't work. The parameter file is created by the developer, who wrote the CDXPatch.exe - I can't change that. Is there any other way in which the current situation can be resolved? – Shivam Gupta Apr 10 '16 at 11:13
  • If you start `CDXPatch.exe` the way you described in your question, do you get the error? Or you only get it when you start `CDXPatch.exe` directly, without using `START`? You could try `echo.O | CDXPatch.exe` and see if it still asks you for O, or for the next parameter. If it asks for O, then my approach won't work. –  Apr 10 '16 at 11:52
  • Sorry, it seems the program does not correctly take input from console, which means I cannot help you. Perhaps you could contact Oracle support and discuss the problem with them. –  Apr 10 '16 at 13:21
  • Thanks a lot for your help till now :) – Shivam Gupta Apr 10 '16 at 13:26
  • There's one more thing you could possibly try: save this file http://codepaste.net/pr8cir as keys.vbs and then start `CDXPatch.exe` as in yout original question, but without the arguments; then, after `START ...` call `keys.vbs [arguments in quotes]`. If this does not work, try adding `/B` argument to `START`. –  Apr 10 '16 at 14:24
  • The "unable to open the parameter file" error probably just means that you forgot to change the current directory before running the command. – Harry Johnston Apr 10 '16 at 23:59
  • Good, but beware of the limited possibilities of the trick. You won't be able to run the patch in the background - the command prompt, in which `CDXPatch.exe` runs, must be in the foreground when the keys are pressed. Otherwise they would be sent to whatever the active window is, instead of your CDXPatch. –  Apr 12 '16 at 12:08
  • I will remember that :) – Shivam Gupta Apr 13 '16 at 06:31
  • @gordon There is a particular CDXPatch.exe which in addition of asking parameters at runtime also asks user to press Enter. I tried passing "{ENTER}" as a parameter but to no avail... – Shivam Gupta Apr 25 '16 at 11:39
  • When does it ask to press Enter? Is it immediately after asking for the arguments, or later? Maybe you could use `WshShell.SendKeys "{ENTER}"` directly in keys.vbs. –  Apr 25 '16 at 20:46
  • Can I create a script which monitors the CDXPatch.exe( opened in a new window using the Start command) requirement for an input and when there is a requirement - it provides it with that – Shivam Gupta May 03 '16 at 14:03
  • It would be possible, but probably not in Batch. You would have to use language from which you can use Windows API functions -- C, C++, C#, VisualBasic, etc.; probably also VBScript or Powershell. By the way, have you run `CDXPatch.exe -h` and read the help? Maybe it can take arguments from the command line, only in a different way than you do it in your question. –  May 10 '16 at 21:00