How to start a program from remote powershell console? - windows-10-iot-core

In the webgui for defaultapp, you can click a button to start the selected app in the drop down.
What command is hidden under that button to start the universal app? I would like to do this from a remote console programatically.
Also, is the source code available for the defaultapp/webgui?

You can use PowerShell to set an app as startup, run in headless mode etc.
Find the details of connecting it with PowerShell here: https://ms-iot.github.io/content/en-US/win10/samples/PowerShell.htm
Also running in headless mode saves more memory, power, faster boot.
Also command line utils for enabling startup process:
https://ms-iot.github.io/content/en-US/win10/tools/CommandLineUtils.htm
-> Default App Sample: https://github.com/ms-iot/samples/tree/develop/IoTCoreDefaultApp
Let me know if you need anything else.

Related

Failed to start native messaging host on Windows, "COMSPEC is not set"

I have a chrome extension that communicates with a native messaging host to get some data.
The issue is, when I launch the Chrome browser via the shortcut or via the pinned shortcut in the taskbar, the extension is not able to connect to the host. I always get the error:
Failed to start native messaging host.
However, if I launch the chrome.exe via command prompt, everything works fine.
Things I tried with no success:
The taskbar shortcut has no extra flags. The target field has the
following value: "C:\Program Files(x86)\Google\Chrome\Application\chrome.exe"
I tried with the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Google\Chrome\NativeMessagingHosts\com.company.extension
I tried with the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.company.extension
I tried with the registry entry under
HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\com.company.extension
Tried launching the chrome.exe as administrator from the file explorer.
Update:
I added the flag --enable-logging --v=1 to the shortcut to enable logging and when I launch it I get the following output in the console:
[11036:4160:0302/113902.866:ERROR:native_process_launcher_win.cc(140)] COMSPEC is not set
[11036:11856:0302/113902.882:ERROR:native_process_launcher_win.cc(140)] COMSPEC is not set
Update
Upon investigating the chrome.exe process via Process Monitor, I found that there is no COMSPEC environment variable available to it when it is spawned via explorer.
Is there anything else that I can try or something that I am missing here?
As mentioned in the log, Chrome stumbles to start an external process, since COMSPEC, an environment variable pointing normally to cmd, is unset:
[11036:4160:0302/113902.866:ERROR:native_process_launcher_win.cc(140)] COMSPEC is not set
The behavior is different for launching Chrome from cmd itself, since it sets the variable for itself (ans spawned processes).
This can be confirmed by inspecting the Chrome process with Process Explorer.
One can run rundll32 sysdm.cpl,EditEnvironmentVariables as admin (e.g. from admin command line) to open the environment variable settings.
Alternatively, the dialog can be navigated to from Control Panel > System and Security > System > Advanced system settings > Advanced > Environment Variables...
ComSpec is usually set in System variables to
C:\WINDOWS\system32\cmd.exe
Adjust as necessary for your system install. For this setting to apply, you need to log out and log back in, or better yet restart the system.

PhpStorm - xDebug on demand not attaching

I tried out your new feature "xedbug on demand". I stuck to these guides (https://www.jetbrains.com/help/phpstorm/2016.3/configuring-xdebug.html and https://blog.jetbrains.com/phpstorm/2016/06/xdebug-on-demand-for-cli-php-scripts-in-phpstorm-2016-2-eap/).
I see that in the php Server menu when I add the path to the xdebug that PhpStorm recognizes it (the label switches from "not installed" to "XDebugger 2.4.1").
So everything seems to be fine but when I use the debugger via the bug-icon, it never attaches/stops for the breakpoint.
I activated the xdebug-Logfile, but it stays completely empty.
Furthermore I commented everything xdebug-related out in the php.ini.
The xdebug-port is still on 9000 (default).
Any ideas what I can do about it?
Update: I'm using the debugger via phpStorm's "PHP Web Application" and the debug-icon. I'm debugging php files which are executed via an apache vHost.
PS: Checked IntelliJ forum and Stack posts, didn't find anything helpful though...
"Xdebug in demand" option works for CLI debugging only (Run/Debug Configuration of "PHP Script" type; will also work for other CLI-mode configs, e.g. "PHPUnit") be it local or remote.
Quote from the aforementioned introduction blog post:
To use the great new feature, first, you need to disable Xdebug for command line PHP scripts.
That option does not work for web pages served via web browser (e.g. Apache/nginx/IIS) or when just listening for any incoming debug connections (Zero-config approach) where actual debug is initiated outside of IDE.
The reason is very simple: when launching debugger for CLI script, IDE launches your php executable (your configured PHP Interpreter, e.g. php.exe on Windows) with additional parameter (-z: check php --help output or here) that can load such additional extension.
But when you debugging a web page then whole PHP is not controlled by PhpStorm: it's your web server (Apache/nginx/IIS/etc) that communicates with PHP .. and you cannot pass such arguments at this stage.

How to replace IotCoreDefaultApp startup permanently. It returns as headed-startup after reboot (sometimes)

Using the newest Windows-10 Iot-Core on a RaspberryPi, I can replace the (single) headed startup/default App via PowerShell command "IotStartup add headed" or I can use the AppXManager to achieve the same. Then I reboot, and the new default/startup headed app appears in the AppXManager as it should.
Sometime later, my Watchdog headless process (background task) then decides to reboot (using ShutdownManager.BeginShutdown(ShutdownKind.Restart, new TimeSpan(0));). After the reboot, the DEFAULT/ORIGINAL IotCoreDefaultApp is sometimes (but not always!) returned to its status as startup app and the headed startup app that I explicitly setup is not started.
How can I assure that IoT-Core does not replace my headed-startup app with the default one upon reboot? I'd prefer not to delete the IoTCoreDefaultApp permanently at this stage in development.
This appears to work now in the newest update-release of iot-core. One can either use the Device-Portal or the "iotstartup" command in powershell. Also, if required, the scripts that handle the default AppStartup are now in C:/AppInstall.
Try to use the IoT Core Dashboard App to connect to your device. And then use the admin page to select the startup App. HTH

How to enable chrome crash dump collection during automated testing?

I know how to enable chrome's crash reporting interactively:
Menu > Settings > Show advanced settings > Tick "Automatically send usage statistics and crash reports to Google"
However, I'm using chrome in an automated testing setup where we set a new --user-data-dir for each run (so there are no persisted settings, we just get the defaults). Chrome is crashing occasionally (running our javascript/html application) and I would like to be able to report these crashes.
I thought I could add --enable-crash-reporter (according to the List of Chromium Command Line Switches), but that doesn't seem to do anything. (We already pass --enable-logging and a couple other flags on the command line.)
I have a test that triggered an "Aw, Snap":
But if I download the user-data-dir for that run and and point chrome at it, and then visit chrome://crashes, it says crash dumps are not enabled.
(The chrome_debug.log does not say anything about the Aw-Snap either.)
We're running chrome under Xvfb on Debian. We're driving chrome via the direct webdriver (from Protractor).
According to the "crashpad with content shell" docs, the steps for using crashpad with content shell (a stripped down version of Chrome):
Create some directory for your crash dumps to go to (the docs suggest tmp/crashes on Linux and Mac, %TEMP%\crashes on Windows, and /data/local/tmp/crashes on Android)
Start Chrome with --enable-crash-reporter --crash-dumps-dir=<your_dump_dir> (looks like you got half of this)
So I'd try adding the --crash-dumps-dir flag.

Enable XDebug in Behat

I am using behat+mink. I wrote some features and am now running tests.
How can I enable xdebug to to stop on breakpoints in phpstorm when running behat tests ?
I have not tried this with Mink yet, but this is configuration that allows me to step through debugging of behat (with behat running on a remote server):
Configure your server with x-debug
Of note, since this is commandline, you need to edit the cli config under /etc/php5/cli/conf.d/20-xdebug.ini.
Set remote_host to the ip of the computer you're using PHPSTORM from
Set autostart = 1
Disable connect_back, you will initiate debugging from the server so there is nothign to connect back to
You can also do this without editing your ini by exporting values as env variables, just remember to do this each time you start a new shell (or add to your .bash_profile file):
export XDEBUG_CONFIG="remote_host=<YOUR IP>"
Configure PHPStorm's Debugger
It seems by default, PHPStorm doesn't understand remote-cli scripts, so we need to add a configuration that tells it to expect a CLI script to trigger xdebug
Open the Run Menu and select "Edit Configurations"
Click the Green "+" to to add a new configuration and select "PHP Remote Debug"
Name the Configuration (E.G. MyServer-Behat)
Under the Servers: menu, select your remote server.
If you haven't configured your remote server yet, then do this by clicking the "..." button on the right
Click the Green "+" to add a server configuration. Give it a name (E.G. MyServer) and fill in it's address under Host
Configure it's Path Mappings. This is important if the path to your source files is different on your PHPStorm computer from your server. You can see in my example that i'm relating my local checkout (~/Work/Symfony/) to my server install (/var/www/). I specifically added mappings for src, bin, web, app, and vendor by clicking in the space to the right under "Absolute path on the server" and typing in the path. I had issues just mapping the root's, so I had to add these paths to get my debugger to work.
Debug!
Once that is setup, select your configuration from the drop down in the debugging tool bar and click the bug icon (you can also use the Run menu) to start the debugger listening. This is similar to the default Telephone Button (circled in yellow), but it tells PHPStorm to use your new configuration.
Now simply run behat like you normally would from your server and your debugger should connect and stop on any breakpoints you've placed.
If you're having doubts about if it's working or not, try toggling the "Break on First Line" in the Run menu, as this should make the debugger break immediately when you run behat (in the bin/behat file)