OS Detection?

I am new to the forum and Arduino in general. So please forgive me if the answer turns out to be simple.

We want to automatically enroll chromebooks using the Pro Micro ATmega32U4. It works great on the chromebook. But causes issues when plugged into a Windows PC, including spitting out the credentials used during enrollment. Is there a way to detect when it is connected to a PC so the program won't run?

My original thought was to check the filesystem for the existence of a file/folder? But I've been unable to dig up anything on how to do that. I would greatly appreciate any insights.

This sounds familiar. https://forum.arduino.cc/index.php?topic=516804.0

Pete

I would turn that around.

Don't have the Arduino start sending out any data (I assume that's over the Serial console) unless asked for explicitly. So your PC has to send a special command, maybe with password, for the Arduino to start sending stuff.

el_supremo: This sounds familiar. https://forum.arduino.cc/index.php?topic=516804.0

Pete

It is similar to that post in that we are both using the same tools for keyboard injection via a USB connection. It gets plugged into the chromebook via USB and then begins injecting keystrokes according to a script to go through the Chromebook enrollment process. That part works just fine.

I am now trying to tweak the code to make it more intelligent and determine if it is plugged into a PC and not a Chromebook so it won't execute the script if someone accidentally plugs it in.

wvmarle: I would turn that around.

Don't have the Arduino start sending out any data (I assume that's over the Serial console) unless asked for explicitly. So your PC has to send a special command, maybe with password, for the Arduino to start sending stuff.

I like that idea and would like to explore it further. I will take a look at Serial Input Basics and some others.

I still would like to have it to not do anything when connected to the PC. This is because we plan on giving some of these devices to non-technical people in remote locations so they can take care of their own enrollment without having to know any of the credentials. But I need to plan on them accidentally plugging it into one of the PCs, which could cause issues. It would also be nice for when I connect it to my PC to upload any changes to the code.

I know that you can do a lot with Arduino. But my problem is that I don't know exactly what it can do. So my basic question is this. Is there any way to plug this arduino into the USB port of a Chromebook or PC and have it query the connected computer to determine what it is?

This might work: Send the keystrokes for hold Windows key down and send R - this will open the Run dialog send "cmd.exe" and Enter - this opens a DOS/command window send "echo whatever" - Now listen on the Serial input for "whatever" to be received. If it doesn't arrive in a reasonable amount of time it's not Windows. There might be a similar process which works on Chromebook in which case your code could try them both.

Pete

el_supremo: This might work: Send the keystrokes for hold Windows key down and send R - this will open the Run dialog send "cmd.exe" and Enter - this opens a DOS/command window send "echo whatever" - Now listen on the Serial input for "whatever" to be received. If it doesn't arrive in a reasonable amount of time it's not Windows. There might be a similar process which works on Chromebook in which case your code could try them both.

Pete

"ver" in the cmd.exe window returns the windows version. e.g. "Microsoft Windows [Version 10.0.15063]" on this machine.

What isn't clear to me is how the Arduino/USB device is registering with the PC. If it is an USB HID device (i.e. emulating a keyboard as suggested in the previous thread), then the response goes to the screen, not back to the USB. If the Arduino behaves as a USB Serial device it could connect as a user terminal in Linux and drive an interactive terminal session, but if that's supported in Windows (I've never seen it done on other than Windows Server versions) then it probably requires specific configuration on the Windows machine.