|
Hi,
I have create a win32 console application. if I run that application, it executes and dissappears. To avoide this i used getch() to hold the application after execution.
Now i don want to use getch(). Insted i would like to use batch file. I few doubts in creating batch file.
1) As this is command line exe..it take few arguments(where user can give the arguemts as he required.). So is it possible for a batch file to take this argument and execute the application with that argument.
2) Is there any other way to deal with this.
Thanks,
Nandu
|
|
|
|
|
Batch files can take up arguments, can run other executables, and can do a lot more perverted things. But my gut feeling is that you should be able to do what you are looking to do without a batch. However, look at the following URL for a batch file tutorial:
http://snipr.com/2uadw[^]
|
|
|
|
|
Hi,
I am working for a project as per the client requirement. We wrote a win32 console application (command line exe). While executing this application its runs and disappears to avoided this I used getch(). But I don’t know the reason, client don’t want to use this getch(). He recommended using batch file. I posted the same question earlier as well, some people suggested to use system("pause"). I don’t the difference between getch() and system("pause"). So I doubt whether client will accept using
system("pause") since he recommended to use batch file.
Which is the better solution here using batch file or system("pause")?
Thanks
Mahadevan
|
|
|
|
|
Why should the application not disappear after it is done? If it should not disappear, why does your client not want you to use getch()?
|
|
|
|
|
As I told you I dont know the reason why we should not use getch(). Is using getch() and system("pause") is same?
|
|
|
|
|
Nandu_77b wrote: Is using getch() and system("pause") is same?
getch() is a Posix[^] function and I shall suggest you to use it or getc() or getchar() . On the other hand, system("pause") is a nasty thing to do, it is a very resource expensive call and it is not POSIX complaint (which means you cannot port it to another operating system).
If you could explain your need better, somebody over here shall give you an appropriate answer. But, avoid the system() call by all means.
|
|
|
|
|
Thanks a lot,
As batch flie helps and its very simple, I am going with batch file rather than getch() or system("pause").
Below thread shows the batch file impl
-Nandu
|
|
|
|
|
Hi
1) Yes, it is possible to pass arguments to a batch file. You use %number to get the argument by counting. For instance:
REM batch.bat
echo %1
echo %2
REM batch.bat
Now you call it "batch.bat Hello World" and the output is
Hello
World
If you have "echo off".
2) A better one =) I call the application from the prompt line, instead of just clicking it. This way, when it finishes, the window is still open and I can see the output.
regards
|
|
|
|
|
Below is the batch file I created. This batch file is used to run a command line exe which takes some parameters. Most of the time, it works with two parameters one for input file and the other for output file.
For example
C:\>myapp.exe input.txt output.txt.
I am just doing the execution using a below batch file.
REM xxx.bat
@echo OFF
%1
%2
%3
%4
myapp.exe %*
pause
But while executing batch file
xxx.bat input.txt output.txt
It opens the input.txt file and after closing the input.txt file it starts executing the myapp.exe with the given paramters.
I don know how to stop opening the input.txt, so that it will not open the input.txt and rather just executes the myapp.exe with the given parameters. Can you please help me to stop opening the input.txt file while executing the batch file.
Thanks,
Nandu
|
|
|
|
|
Sorry this question and just a general reply, in the above i forgotten to mark as question.
Below is the batch file I created. This batch file is used to run a command line exe which takes some parameters. Most of the time, it works with two parameters one for input file and the other for output file.
For example
C:\>myapp.exe input.txt output.txt.
I am just doing the execution using a below batch file.
REM xxx.bat
@echo OFF
%1
%2
%3
%4
myapp.exe %*
pause
But while executing batch file
xxx.bat input.txt output.txt
It opens the input.txt file and after closing the input.txt file it starts executing the myapp.exe with the given paramters.
I don know how to stop opening the input.txt, so that it will not open the input.txt and rather just executes the myapp.exe with the given parameters. Can you please help me to stop opening the input.txt file while executing the batch file.
Thanks,
Nandu
|
|
|
|
|
Thanks,
I got the solution, I have use ECHO as shown below.
Forum: Visual C++ / MFC
Subject: Re: About batch file
Sender: Nandu_77b
Date: Monday, July 7, 2008 1:14 AM
Sorry this question and just a general reply, in the above i forgotten to mark as question.
Below is the batch file I created. This batch file is used to run a command line exe which takes some parameters. Most of the time, it works with two parameters one for input file and the other for output file.
For example
C:\>myapp.exe input.txt output.txt.
I am just doing the execution using a below batch file.
REM xxx.bat
@echo OFF
ECHO %1
ECHO %2
ECHO %3
ECHO %4
myapp.exe %*
pause
-Nandu
|
|
|
|
|
It opens the file because of these lines:
%1
%2
%3
%4
You should write only:
REM xxx.bat
@echo OFF
myapp.exe %*
pause
If %1 is equal to "input.txt", them writing %1 just like that will open input.txt with the default application (usually notepad).
Hope i'v helped =)
Fratelli
|
|
|
|
|
Thanks a lot...it helped me very much.
- Nandu
|
|
|
|
|
hi
last week i attend one interview ,they asking one question in MFC .
i have one txt file which is contains.... numbers 1 2 3 4 5
my question is
how to sort in 3 digit form
like this:
123
134
145
234
245
251
345
351
312
451
412
423
512
523
534
i need this kind of output in xml file .
i need this kind of way ....i hav no idea abt how to get output..
thanks and regards
Nisha
|
|
|
|
|
You can use something like this:
#define next(i) ((i) < 5 ? (i) + 1 : 1)
#define previous(i) ((i) > 1 ? (i) - 1 : 5)
int main()
{
unsigned i, aux, j, cnt;
for (i=1 ; i<6 ; i++)
{
for (aux = next(i) ; aux != previous(i) ; aux = next(aux))
{
cout << i << aux << next(aux) << endl;
}
}
return 0;
}
The "next" macro increments a value until it reaches 5. When such happens, it returns to 1. The "previous" macro does the opposite, when the value reaches 1 it returns to 5.
regards
|
|
|
|
|
yes thanks ..but i want to this output into XML format...
|
|
|
|
|
In what format? You can always output the XML tags with the values... I just don't know for sure which tags you intend on using.
Regards
Fratelli
|
|
|
|
|
can anybody tell me how to set static IP address using c++ code using win32 API
|
|
|
|
|
you could try to have a look at the ip api... but most of it is pretty undocumented, so good luck 
|
|
|
|
|
sounds like a disaster in the making to me mate.
hard coding an IP address is going to fall over sooner or later depending on the network config.
i would ask if u really need to set a static IP addr or weather u can use a "localhost" type workaround
|
|
|
|
|
yes,my application requires so.could u pls help?my code is showing unhandled exception in this line
HRESULT hr = pSvc->GetObject(ClassName,0,NULL,&pClassObj,NULL);
|
|
|
|
|
|
HI all,
There is any class in MFC like PrintPreviewDialog.
Please tell me which class is use inplace of PrintPreviewDialog.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Print preview comes incorporated in most MFC doc/view apps if you choose it in the wizards.
You have to supply the correct drawing code of course.
|
|
|
|
|
In MFC,CPageSetupDialog for page setup and CPrintDialog for print dlg is available.
So i just want to know there is any class for PrintPreviewDialog.
I know that:
bob16972 wrote: Print preview comes incorporated in most MFC doc/view apps if you choose it in the wizards.
But i want to show it at a particular place, so i want to know about class which is related to printprevieewdlg.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|