8

Simple question, probably a simple answer. ;(

Is there a way to run PowerShell on my Windows Phone?

If not, is there another way to get to a legit console/terminal? Right now I have "Console WP8 Lite", which is clearly only an emulator. My phone isn't rooted right now, but I'd be interested to know if rooting would give me access to something like that.

  • PS. I am familiar with MS-DOS Mobile, but that is completely different because it runs in a virtual environment. – Aaron Campbell Jul 8 '16 at 1:33
  • 1
    I love PowerShell, but what kind of use cases do you imagine on a phone? – Peter Hahndorf Jul 10 '16 at 14:30
  • That's actually a very good question. Reading root directories, running system exe's, running scripts, networking stuff. – Aaron Campbell Jul 11 '16 at 16:29
  • Keyboard input on a phone is kind of awkward, but being able to remote into a phone and get a shell is pretty useful (see the popularity of SSH servers on rooted Android and iOS devices). It's actually easy to get a telnet server running CMD (yes, real CMD.EXE, for what it's worth) on the phone, and of course you could get an app that wraps the shell I/O in UI that you can use, but it only runs with app permissions (can't read most of the file system, etc.). On a rooted phone, you could run that with more permissions, but rooting W10M is hard. – CBHacking Jul 11 '16 at 20:29
  • @CBHacking I would love to get that working on my phone! Can you link to an article or something explaining how to do what you're describing? – Aaron Campbell Jul 12 '16 at 1:15
6

The answer is No. You cannot run a Powershell in winodws mobile. Not until Microsoft implements it. I suggest you to upvote the feedback in the Feedback Hub.

What about 3rd party apps?

Third party apps, particularly the ones distributed via store cannot bring the full functionality of Powershell due the limiations that are there for security of the OS.

My phone isn't rooted right now, but I'd be interested to know if rooting would give me access to something like that.

There is no rooting Windows 10 mobile. You can hack into Windows registry to make changes to the OS. Hacking into the registry is not Rooting. You can edit the registry but you cannot have Powershell on Windows mobile.

Update:

Upon seeing CBHacking's answer I think it may be possible to read run scripts, read root directories, etc... It is not easy as rooting an Android but if you are ok with such things you could give it a try.

  • There are all sorts of XDA posts (etc) about "rooting" Windows phone; I'm sure it's very different from rooting Android, but that's what I was referring to. – Aaron Campbell Jul 8 '16 at 20:52
  • Powershell is pretty complex, although in theory there's no reason it (or an equivalently-powerful shell) couldn't be brought to Windows phones. As for rooting, it's pretty easy on a lot of Windows Phone 8.1 devices, but harder on Win 10 Mobile. There have existed "root" (arbitrary code execution with arbitrary permissions) hacks for W10M, but the OS as a whole is such a moving target that it's really hard to keep up. They were also only relevant on some pretty old phones (ones that shipped with WP8.0). – CBHacking Jul 11 '16 at 20:23
  • @CBHacking There is a reason that Powershell cannot be brought to Windows mobile without MS making it. The reason is the restriction on the OS. Apps cannot access a number of things such as others apps. system files, etc... The question asks to run Powershell for Reading root directories, running system exe's, running scripts, networking stuff. As far as I have seen a third party app in the store cannot do it. – Kolappan Nathan Jul 12 '16 at 10:12
  • @AaronCampbell Yes, there are some posts about that. Some have actually done it. But these procedures change a lot with each major update. Also as far as I know it is not working on Windows 10 mobile. But seeing the comment of CBHacking I may be wrong. I would happily admit it if he explains how to do it. – Kolappan Nathan Jul 12 '16 at 10:23
  • @KolappanNathan: Who said anything about "from the store"? The question explicitly mentions rooting; I assume anybody willing to do that isn't going to flinch from sideloading an app. Trust me, I'm familiar with the restrictions on third-party apps; I find them too restrictive, which is why I develop methods to bypass them. Reading the root of C: on the phone is hard, but not impossible; just getting a shell running is pretty easy (the main difficulty running Powershell would be that .NET-based EXEs are only sort-of supported; Win32 ones run fine if you import CreateProcess). – CBHacking Jul 12 '16 at 19:40
1

There's a basic shell program (which supports CMD-like commands, though it isn't actually running CMD) available on XDA-Devs here. It's an old version (1.5 years) and I should bug the dev about updating it, but it provides some ability to browse the file system and registry. You have to connect to it using a Telnet-like protocol (PuTTY works).

It can run EXEs, though they'll only have the same permissions as the app itself (not much, unless you elevate it by hijacking a more-privileged chamber or launching it as a Windows Service using a rooting hack, such as WP Internals). You can get a number of EXEs that will run (unmodified) on WP8.x/W10M by extracting them from the UpdateOS.wim file on the phone. Notably, this includes CMD.EXE (the real deal, make sure you also grab its .MUI file from the appropriate region directory like en-us), TELNETD.EXE (a basic Telnet server, syntax is telnetd <program> [port] so you could use telnetd cmd.exe or telnetd cmd.exe 22222), and FTPD.EXE (a basic file transfer protocol server, you can optionally specify a folder to root the FTP access in). I've seen copies of other real Microsoft EXEs, like REG.EXE, NETSH.EXE, BCDEDIT.EXE, SC.EXE, etc. but I do not now remember where I found them and they aren't on my current PC (and they mostly require elevated privileges to be of any use, anyhow).

Note that this isn't going to actually root the phone in any way by itself, it's just another way to access the data on it (including some data not normally visible). Another way to do this is to use an app such as the Native Access Web Server, which gives (partial, and mostly read-only) access to the file system and registry via a web browser.

Note that none of these tools I've linked have any authentication or encryption; don't use them on untrusted networks unless you want to risk total strangers connecting to your phone. You will have to use WiFi; cellular blocks incoming connections and loopback is blocked by the OS security model.

1

Given that you are running Windows 10, you can actually run T-Shell from your host computer and connect to your device.

I have only done this on non-retail devices. Download and install WDK 10: https://developer.microsoft.com/en-us/windows/hardware/windows-driver-kit

By having the device connected via USB cable you can connect to the device via open-device 127.0.0.1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.