2

I want to use the Google Assistant SDK to make a Google Assistant desktop app for Windows. I want to access the SDK using python, and pass input to the python command.

For example, you talk to Google Assistant using this Python command:

python -m googlesamples.assistant

If you have python installed you can run that in CMD, so either that or directly running the python command.

I have tried this:

string strCmdText;
strCmdText= "/C copy /b Image1.jpg + Archive.rar Image2.jpg";
System.Diagnostics.Process.Start("CMD.exe",strCmdText);

but it says that System.Diagnostics.Process does not exist.

Can someone help with this?

NateDev
  • 141
  • 5
  • 14
  • which IDE, compiler, versions do you use? what is the full compiler error message? `System.Diagnostics.Process` is defined in System.dll, so no extra reference shoud be required to use it. – Cee McSharpface May 07 '17 at 15:53
  • @dlatikay The type or namespace name 'Process' does not exist in the namespace 'System.Diagnostics' (Are you missing an assembly reference?) I'm using VS 2015. It's a Windows desktop app and not a console project, Winforms etc. CLR v4.0.30319 – NateDev May 07 '17 at 15:56
  • In Solution Exporer, expand the "References" folder and look if "System" is missing as a reference. – Cee McSharpface May 07 '17 at 15:59
  • Possible duplicate of [Process Class Not Found in System.Diagnostics? (System.dll???)](http://stackoverflow.com/questions/7572150/process-class-not-found-in-system-diagnostics-system-dll) – Cee McSharpface May 07 '17 at 16:01
  • In references there is only Analyzers, .NET For Windows Store apps and Windows 8.1. However if I try to add system.dll manually it says it's already referenced. – NateDev May 07 '17 at 16:02
  • Then it is probably bad news: this project type runs in a sandbox and may not launch processes: http://stackoverflow.com/a/12765721/1132334 Maybe you could choose another, less restricted project type? – Cee McSharpface May 07 '17 at 16:08
  • Why is this? So that means I have to either use WPF or WinForms then? – NateDev May 07 '17 at 16:09
  • but you may still succeed using [this approach](http://stackoverflow.com/a/12767030/1132334), when Python is properly registered in the runtime environment, pack the command in a Python script file (.py) and launch the script file. – Cee McSharpface May 07 '17 at 16:10
  • Is there a tutorial or a detailed explanation on how to do that? – NateDev May 07 '17 at 16:12
  • basically, just `bool succeeded = await Windows.System.Launcher.LaunchFileAsync(@"call_googlesamplesassistant.py");`. More [here](https://learn.microsoft.com/en-us/uwp/api/windows.system.launcher) – Cee McSharpface May 07 '17 at 16:26
  • OK, I followed the instructions on that link, however when the python script runs I don't see anything. I tested that it is indeed working by launching a URL and that worked properly. This is the code I used: `string scriptFile = @"Assets\Scripts\hello.py";` `var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(scriptFile);` `var success = await Windows.System.Launcher.LaunchFileAsync(file);` – NateDev May 07 '17 at 17:09
  • I just saw this: http://stackoverflow.com/questions/24402789/how-can-i-run-a-command-in-windows-store-app which says that executables are blocked, so I guess that I will have to change project types. It really should let you do this if you are not releasing the app to the store, just using it personally. – NateDev May 07 '17 at 17:26
  • 1
    I agree with that... but if you don't need to distribute it to the Windows Store, changing the project type is a valid option. there is [another related thread](http://stackoverflow.com/a/34598918/1132334) – Cee McSharpface May 07 '17 at 18:04

0 Answers0