File Access takes me to command prompt rather than Explorer - windows

Whenever I go to my command prompt and type a "c:\temp" or any other file/directory, it takes me to the command prompt rather than the file explorer. Can somebody please tell me how I can fix this so that all file/directory access from cmd takes me to the file explorer.
I have a Win2k3 64bit machine. Has this got anything to do with the 32bit/64bit explorer ?

To run Windows Explorer from command prompt you must type name of the executable:
explorer.exe
or just
explorer
To open a certain folder, pass the path as an arguments. Details here:
Command-Line Switches for Windows Explorer (MSDN KB)
See examples.

To open Explorer at the directory where your cmd is operating you can use
start .
and at a parent directory you can use
start ..

Related

How to open 'This PC' using CMD or Powershell?

I need a way of opening the explorer at This PC , in the same way as opening in a windows explorer Gui, but I am incapable of this as using Explorer.exe in CMD opens quick access.
I tried opening it with a shortcut and that too failed.
Does anyone know of a way to do this?
Cheers
Just like you can run explorer.exe C:\ to open up the C: (or any other drive or folder path), you can also use a file: URI to open paths in Explorer as well. If you just specify the file: protocol without a directory (or specify file:\\), it will open This PC:
explorer file:
explorer file:\\
Note that you can also change the default Explorer location from Quick Access to This PC as well from Folder Options:
You can set this in the registry too if you're after automation to configure this. See my answer on how you can use PowerShell to set the default launch folder in the registry.
My experience is that, the following should work:
From cmd:
Start "" "%SystemRoot%\explorer.exe" /Select,"This PC"
From powershell:
Start "$Env:SystemRoot\explorer.exe" "/Select,'This PC'"
You can use this in cmd:
Explorer /root,
On Powershell, we can do this:
(New-Object -ComObject Shell.Application).Namespace("").Self.InvokeVerb()
We create a com object of class Shell.Application, then call
.InvokeVerb() that invokes the default verb "open".
Or more rigourously, by defining ssfDRIVES constant (see Microsoft reference)
Set-Variable ssfDRIVES -Option Constant -Value 0x11
(New-Object -ComObject Shell.Application).Namespace($ssfDRIVES).Self.InvokeVerb()
ssfDRIVES 0x11 (17). Namespace points to My Computer—the virtual folder that
contains everything on the local computer: storage devices, printers,
and Control Panel. This folder can also contain mapped network drives.
Open the Command Prompt and type this in:
explorer =

Command prompt from C: drive, how to start executable in another drive?

I have a Windows machine with the current user in C:\Users\User.
I have an executable in another drive, let's say at D:\Folder\MyProg.exe.
Opening command prompt, it starts in the directory C:\Users\User
I type the command: start D:\Folder\MyProg.exe or D:\Folder\MyProg.exe
The exe fails to open, with a pop-up: MyProg has encountered an error
In order to run start the .exe from command prompt, I have to cd to the other directory and then start the exe.
Opening command prompt, it starts in the directory C:\Users\User
I type the command: cd /d D:\Folder && start MyProg.exe
The exe successfully opens.
Is there a better way to, from C:, start an executable in another drive?
Reproducing
Windows 10 Pro, v1809 (I don't think the version really matters)
My real use case is industrial automation, but one can observe the same result with convert.exe (cnet download link)
As commented by #Mofi, I realized the answer is most likely this:
But some programs are not good coded. Such programs depend on files in directory of the program and do not use appropriate code to reference those files from within the program with program files path, but use instead a relative path
As he instructed in the next comment, start provides a /d parameter that lets you specify a startup directory. Thus, a concise command would be:
start "" /d D:\Folder MyProg.exe
Note: the "" is for the <Title> field. The .exe I am opening is a GUI application (not a console application), so it is not necessary in this case, I just included in case other viewers find this useful in their application.
I have a Windows machine with the current user in C:\Users\User.
I have an executable in another drive, let's say at D:\Folder\MyProg.exe.
Opening command prompt, it starts in the directory C:\Users\User I type the command: start D:\Folder\MyProg.exe The exe fails to open.
In order to run start the .exe from command prompt, I have to cd to the other directory and then start the exe.
Maybe not. Try:
PATH D:\Folder;%Path%
"D:\Folder\MyProg.exe"

Why is the PowerShell prompt different when opened from a directory?

I have the habit of using the caps+right click option "Open PowerShell prompt here", and I noticed it doesn't have the same prompt as when I open it from the start menu:
The font is way bigger when opened from a directory
The PATH used seems to be different (which is the main problem here)
For the second point, I have an foo.exe with its directory in the PATH (both System and my current user).
If I open PowerShell from the start menu, type "foo.exe", it executes.
If I use "Open PowerShell here" and type "foo.exe", I get a CommandNotFoundException.
What I would like is both to understand why there is a difference, and how to put my directory somewhere where I can "foo.exe" in any context.
PS: I'm using Windows 10 Creators Update

How to set ps as shortcut to open powershell

The question says it all. I want to learn and use powershell as my go to terminal in windows and I want powershell to open if I type Win+R followed by ps. Much like how cmd is used to open command prompt.
You can create a symbolic link (similar to a shortcut) to Powershell with any name you want.
This will create one called ps.exe in the powershell folder, this folder is already listed in PATH so will enable you to run ps from the RUN box like you want.
mklink %SystemRoot%\system32\WindowsPowerShell\v1.0\ps.exe %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
Be sure to run the command in an elevated command prompt.
The "default" command for opening PowerShell is powershell. If you want to make it ps, your best bet is to create a batch file named ps.bat containing the single line
#powershell %*
and place it in one of the directories named in your system PATH variable.

How to restore bat file execution from explorer on XP

some bat files need to be launched at the start of the session, but they don't.
Actually, when trying to launch one from the explorer, it opens the Open with window instead of just runnig.
However, the bat files still run correctly from the command prompt.
I bet it has been caused by a virus, but the antivirus did not detect anything unfortunately.
Any idea?
Use the Open With command, select cmd.exe, then before you hit OK, check the box that says "always use this program to open this type of file" or something similar.
If cmd.exe is not in the choices, browse to c:\windows\system32, and cmd.exe should be in there.
You can re associate the extension by downloading the reg file for batch from the link below which should solve your problem.
http://www.dougknox.com/xp/file_assoc.htm

Resources