Click here to Skip to main content
15,886,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having two different exe files.
If I click a button from one exe the values in the textboxes(say 3 textboxes) should passes to another exe so that I may use it in the second exe file.

I have tried some codes and got Access is Denied Exception.

Can anyone help me to get rid of this problem.


Exception: ACCESS IS DENIED

EXE 1
C#
 Application.EnableVisualStyles();
            
Application.SetCompatibleTextRenderingDefault(false);

Global.Passingvalues =  OrderXML + "," + Global.CurrentView+ "," + strOrderId;

System.Diagnostics.Process startApp = new Process();

System.Diagnostics.ProcessStartInfo psiview;

psiview = new System.Diagnostics.ProcessStartInfo(orderPath, Global.Passingvalues);
                        
startApp = System.Diagnostics.Process.Start(psiview);
                        
startApp.WaitForExit();


EXE 2
C#
 static void Main(String[] arg)
{ 
 Application.EnableVisualStyles();
            
 Application.SetCompatibleTextRenderingDefault(false);

 frmSplashW frmSpl = new frmSplashW();                  

 Application.DoEvents();

 string[] passedString = new string[3];

 passedString = arg[0].Split(',');

 orderXML = passedString[0];//"";// arg[0];
                    
 currentView =passedString[1] ;//"";//arg[1];
                    
 orderID = passedString[2];//"";//arg[2];                

 frmSpl.LoadInitRMSBusiness(orderXML,currentView,orderID);
                    
 Application.Run();
}
Posted

1 solution

The way you are passing your parameters is odd. Normally a space is used to separate them and each gets put into a different element of the arg array. If any of the things you are supplying has a space in it, you'll get some very weird results.

BTW double-quote anything with a space in it.

As far as the access denied is concerned, unlikely to be to do with the command line. Access is denied is what you get when you don't have permission to do something. The second process will be a child of the first, as such it will inherit its security token. Does the account the first thing running under have access to run the second?
 
Share this answer
 
Comments
KUMAR619 21-Jul-14 7:16am    
I've tried using space in between parameters but the same exception happens.

How to give permission to the EXE by means of security token.
Can you explain Sir.
Rob Philpott 21-Jul-14 7:20am    
Most likely thing is that the second exe is somewhere which is not accessible to the account that the is executing the first. Try running the second exe as the first account and see what happens.
KUMAR619 21-Jul-14 7:28am    
Second EXE runs only when its gets parameters from the first exe.
Please help Sir
Rob Philpott 21-Jul-14 7:32am    
It's an exe which takes command line parameters - you can run it. You need to try in order to find out what is going wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900