Reputation: 21
I am developing a WPF application, that has a function to run the "CMD" in user pc and navigate to one folder "platform-tools" that included in the application files and execute a command.
string Request = " /c" + "cd../../&cd platform-tools& adb reboot ";
Process procc = new Process();
ProcessStartInfo procStartInfo2 = new ProcessStartInfo(@"cmd.exe", Request);
As we know, when the user install the application in his PC, the application will be located in C:\Users\""UserName\AppData\Local\Apps\2.0\"random name like: JBJHV6HG7HG" so its difficult to know where is exactly the "platform-tools" will be installed.
My question is: is there any way i can know how to reach the platform-tools folder by my "Request" in order to rung the adb command?
or
is there a way to install the "platform-tools" in different location like "User's desktop" then i can change the "CD" command in CMD to navigate to user's desktop or C drive?
Upvotes: 0
Views: 81
Reputation: 71
Using the ClickOnce, you won't be able to change the destination install folder due some security features and so on... you can find out more Here
You can get the path of your executing process, and concatenate the folder name to reach the "platform-tools" folder:
//There's two ways to get the current file address from your application (in the end both ends in the same):
//There's two ways to get the current file address from your application (in the end both ends in the same):
//getting the filename by the process
var cc = Process.GetCurrentProcess().MainModule.FileName;
//getting the filename by the executing assembly
var dd = System.Reflection.Assembly.GetExecutingAssembly().Location;
//getting the path for that file name
string assemblyPath = Path.GetDirectoryName(cc);
var platformTools = string.Concat(assemblyPath, @"/platform-tools/someprocess.exe");
Process.Start(platformTools);
Upvotes: 1