execute .bat file
-
CString csFilePath = _T("D:\\myFolder\\mybat.bat"); //contains the path of my bat file. int iReturn = (int)ShellExecute(NULL,_T("Open"),csFilePath,NULL,NULL,SW_SHOWNORMAL); In MSDN it is written that if iReturn is greater than 32 then shellexecute() is successfull and if it is less than 32 then unsuccessfull. and I have written the error message already to you.
Madan Chauhan wrote:
I have written the error message already to you
and so, the message doesn't talk to you ? What it means is perfectly clear to me. maybe you should read it again ;) You could use Process Explorer[^] and close the handles of the applications using this file...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Madan Chauhan wrote:
I have written the error message already to you
and so, the message doesn't talk to you ? What it means is perfectly clear to me. maybe you should read it again ;) You could use Process Explorer[^] and close the handles of the applications using this file...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
Anyway Dear sir, may be I am wrong or doing some fault in code. My problem is only that how can I execute a batch file in vc++? I am not concerning only in Shellexecute(), if there is any other way, please guide me.
-
Anyway Dear sir, may be I am wrong or doing some fault in code. My problem is only that how can I execute a batch file in vc++? I am not concerning only in Shellexecute(), if there is any other way, please guide me.
Madan Chauhan wrote:
My problem is only that how can I execute a batch file in vc++?
exactly the way you do ! if you had ask me to launch a .bat from my exe, I would have written the same code for sure !
Madan Chauhan wrote:
I am not concerning only in Shellexecute(), if there is any other way, please guide me.
yes, there are, but i find them not as much elegant than ShellExecute(), and this cannot be the reason. The reason is (as the error message said), that some file is being used by another process (another application. use ProcessExplorer (very lightweight) to find which is the culprit...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Madan Chauhan wrote:
I have written the error message already to you
and so, the message doesn't talk to you ? What it means is perfectly clear to me. maybe you should read it again ;) You could use Process Explorer[^] and close the handles of the applications using this file...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
Thanks Sir, My net got slow thats y I could not read your latest reply. Now I am doing it well after closing the handle. Thank you very much.
-
Hi all, How can I execute .bat file using vc++. I am trying to execute it by using ShellExecute() function but it is not executing. ShellExecute(NULL,_T("Open"),"_T("D:\\myBat.bat"),NULL,NULL,SW_HIDE); It is returning less than 32, but if it is successfully executed it should return greater than 32. Please provide me the solution. Thanks.
You can also use of CreateProcess.
-
Madan Chauhan wrote:
I have written the error message already to you
and so, the message doesn't talk to you ? What it means is perfectly clear to me. maybe you should read it again ;) You could use Process Explorer[^] and close the handles of the applications using this file...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
Hi toxcct I have a error in my code.And Mr. Rajesh R Subramanian tell me that i talk to you about that problem.My problem is that .exe file is not copy and .txt file is copy.I am useing get last error then i have found Error no. 32.
The process cannot access the file because it is being used by another process.
I am useing this code
CString cs = _T("C:\\Backup\\");
cs += PathSkipRoot(strFileName);
//CopyFile(strFileName, cs, TRUE);
if ( !CopyFile(strFileName, cs, TRUE))
{
DWORD dwError = GetLastError();
CString szMsg;
szMsg.Format(_T("Error number %d"), dwError);
AfxMessageBox(szMsg);
}
else
{
AfxMessageBox(_T("Success"));
}Sir plz help me
-
Madan Chauhan wrote:
My problem is only that how can I execute a batch file in vc++?
exactly the way you do ! if you had ask me to launch a .bat from my exe, I would have written the same code for sure !
Madan Chauhan wrote:
I am not concerning only in Shellexecute(), if there is any other way, please guide me.
yes, there are, but i find them not as much elegant than ShellExecute(), and this cannot be the reason. The reason is (as the error message said), that some file is being used by another process (another application. use ProcessExplorer (very lightweight) to find which is the culprit...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Madan Chauhan wrote:
My problem is only that how can I execute a batch file in vc++?
exactly the way you do ! if you had ask me to launch a .bat from my exe, I would have written the same code for sure !
Madan Chauhan wrote:
I am not concerning only in Shellexecute(), if there is any other way, please guide me.
yes, there are, but i find them not as much elegant than ShellExecute(), and this cannot be the reason. The reason is (as the error message said), that some file is being used by another process (another application. use ProcessExplorer (very lightweight) to find which is the culprit...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
-
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
i'm aware of this. that's why I didn't answer his today's post to me... the OP doesn't take in account the answers he got, so i stopped wasting my time and energy with him :cool:
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
i'm aware of this. that's why I didn't answer his today's post to me... the OP doesn't take in account the answers he got, so i stopped wasting my time and energy with him :cool:
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]