Locate a desktop shortcut with the command prompt or Powershell - windows

I'm trying to use the command prompt or Powershell to locate some of the shortcuts that an installed program has created on my desktop. For Example, Adobe Reader has created a shortcut on my desktop. I try to use dir "c:\Users\MyUserName\Desktop", but I do not see this shortcut.
How can I find this shortcut through a command prompt or with powershell?

Shortcuts are files with extension ".lnk" and would be displayed by dir ( cmd and powershell)
I think some shortcuts (.lnk files) are created at c:\users\public\Desktop so that they can be shared by all users. ( shortcuts placed in this location are available on the desktop of all the users)
More about the "Public user" here: http://windows.microsoft.com/en-US/windows-vista/Sharing-files-with-the-Public-folder
So you may want to look in that location as well.

Related

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

Can't find Cmder in program files

I've been having trouble finding the cmder inside windows program files. I wanted to make a shortcut to it so that I can easily access it using windows docker but can't find the location. I only have cmder now pinned on my taskbar but I would like to know it's directory path. Thanks in advance.
I am using windows x64bit
Open a command line window.
Enter "dir Cmder.exe /s"
It's relative to where you installed it. To find out right-click cmder in your taskbar, and you will see that it says "cmder.exe - shortcut", right-click it again and access properties. In the target field you will see your path.

Creating shortcut with a simple command in CMD.exe

I need a code for cmd.exe for creating a shortcut on any user's desktop.
If the application will be in the same folder on all machines (like C:\Program Files\Software\Start.exe) then create a shortcut, place it on a network drive, or in the .cmd file's folder, and simply just copy it to C:\%username%\Desktop

Changing default startup directory for command prompt in Windows 7

How do I change default startup directory for command prompt in Windows 7?
I usually do the following to start command prompt from C:\
WIN-R (Run Prompt)
cmd /K cd C:\
I want to do the following to start command prompt from C:\
WIN-R (Run Prompt)
cmd
Make a shortcut pointing to cmd.exe somwhere (e.g. desktop) then right-click on the copy and select "properties". Navigate to the "Shortcut" menu and change the "Start in:" directory.
The following solution worked well for me. Navigate to the command prompt shortcut in the start menu:
C:\Users\ your username \AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Command Prompt
Right click on the shortcut file to open the properties dialog. Inside the "Start in:" textbox you should see %HOMEDRIVE%%HOMEPATH%. If you want the prompt to start in C:\ just replace the variables with "C:\" (without quotes).
update
It appears that Microsoft has changed this behavior recently and so now an additional step is required. After performing the steps above copy the modified shortcut "Command Prompt" and rename it to "cmd". Then when typing "cmd" in the start menu it should once again work.
Open regedit and browse to this path
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
Create new string vale named Autorun. Set its value to cd /d C:\.
Run cmd again. Voila!
While adding a AutoRun entry to HKEY_CURRENT_USER\Software\Microsoft\Command Processor like Shinnok's answer is the way to go it can also really mess things up, you really should try to detect a simple cmd.exe startup vs a script/program using cmd.exe as a child process:
IF /I x"%COMSPEC%"==x%CMDCMDLINE% (cd /D c:\)
Easiest way to do this
Click "Start" and type "cmd" or "command prompt".
Select Top most search application named exactly same "cmd" or "command prompt".
Right Click on it and select "Send To"=>"Desktop".
On Your Desktop New "cmd" Shortcut will appear
Right Click on that icon and choose "properties"
Popup will appear, In "Shortcut" Tab Type the new location in "Start In" option (e.g D:\xyz)
Drag that icon and add/pin it in "Task Bar"
On Windows Start Menu, right click on Command Prompt.
Click on "Properties".
"Command Prompt Properties" dialog box opens.
Edit the field "Start in " to a location where you want to start the command prompt.
Example: Chand %HOMEDRIVE%%HOMEPATH% to D:\PersonalPrograms.
Next time when you start command prompt the start up directory will be D:\PersonalPrograms
Bit late but ignore the registry mods.
Simply change the shortcut target to:
cmd /k "command"
i.e.
cmd /k "cd\myStartUpFolder"
Voila!
This doesn't work for me. I've tried this both under Win7 64bit and Vista 32.
I'm using the below commandline to add this capability.
reg add "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v AutoRun /t REG_SZ /d "IF x"%COMSPEC%"==x%CMDCMDLINE% (cd /D c:)"
I think the easiest way is to make a cmd shortcut, then change the shortcut's "Start in" directory to the one you want to start with.
On windows 7:
Do a search for "cmd" on your Windows computer
right-click cmd and left click "Pin to start menu" (Alternatively, right-click cmd - click copy and then paste to your desktop )
right-click the cmd in your start menu or on your desktop (depending on choice 2 above) - left click properties
inside the "start in" text box paste the location of your default start directory
Press Apply and OK
Every time you click on the cmd in your start menu or your desktop shortcut, the CMD will open in your default location
changing shortcut under Windows System on 8.1 worked for me - another thing I found is that 'Start In:' WORKS when Advanced -> Run as admin is UNCHECKED, however, if CHECKED, it does not work
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
string: Autorun
value: cd /d %~dp0
all bat files will run from the bat file location
One easy way to do it + bonus.
Start cmd with administrator rights, the default directory for the prompt will be C:\WINDOWS\system32.
I created a bat file in that directory (notes.bat)
Opened it with notepad and wrote the following lines. Each line is followed with a comment which should not be added to the bat file.
#echo off
prompt $S$CYourNamel$F$S$G$S
/* This is a comment, do not include it in the bat file - above line will make the prompt look like (YourName) > */
cd C:\Your_favorite_directory
/* This is a comment, do not include it in the bat file - above line will navigate you to your desired directory */
Saved the file and that was it.
Now when You open cmd with admin rights, just write: notes or notes.bat
and it will execute the notes.bat file with desired changes.
go to regedit ( go to search and type regedit)
expand "HKEY_CURRENT_USER" node
under HKEY_CURRENT_USER node expand "software" node
under software node expand "microsoft" node
under microsoft node click on "Command Processor"
path looks like this : "HKEY_CURRENT_USER\Software\Microsoft\Command Processor"
it looks something like this :
if you do not see "Autorun" String Value
Right Click - New - Expandable String Value, and rename it to Autorun
double click on "Autorun"
10.enter this value path format:
"CD/d C:\yourfoldername\yoursubfoldername"
Edit: It actually seems that editing the file shortcut breaks the Win+x, c key shortcut. (Moral of the story: only change system files you know how to fix! Eventually after a Windows update it repaired itself.)
What I ended up doing is creating a new customized Command Prompt shortcut in the start folder and pinned to the taskbar that I launch instead of cmd.exe
As other answers point out, changing the registry Autorun cmd start location is a bad idea because it silently will break other programs that shell out for tasks, like Visual Studio Code.
You should just change whatever shortcut you use to open cmd to have a Start In entry.
If you use Win+x, c to launch cmd, you can edit the Start In for
"%LOCALAPPDATA%\Microsoft\Windows\WinX\Group3\02 - Command Prompt.lnk"
type
cmd.exe /k cd c:/
in a text file and save as cmd.bat Clicking this file does the trick. You can pin it to the start menu as well.
To start in a partitioned drive (e.g. D), use
cmd.exe /k d:
My default dir was system32 when starting CMD.
I then created a batch file in that directory to change dir to the one I was after.
This caused me to always call that bat when starting CMD every time.
So I made a reg file & put this inside:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"Autorun"="cd C:\\Users\\Me\\SomeFolder"
After saving it, I opened the file, clicked ok to merge with registry, and since then every time I open CMD, I get my dir
In the new Windows Terminal, you can click Settings and edit the line "startingDirectory" to achieve something similar.
Please note, however, that this changes the default startup directory only in Windows Terminal, and not for the command prompt globally.
Use Windows Terminal and configure a starting directory.
Partial settings.json:
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": false,
"startingDirectory": "C:\\DEV"
},
HKEY_CURRENT_USER\Software\Microsoft\Command Processor is no longer valid.
The new key is here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
Change "Autorun" to "CD /d C:\YourFolder" (without double quotes)
Keep the opening of the command prompt clean. Avoid editing the registry key and adding an Autorun, it may come back to bite you.
Create a simple batch file and save it in the C:\Windows or C:\Windows\System32 folder. I call mine !.bat (exclamation mark). It has the following commands:
#echo off
c:
cd \
cls
whoami
It goes to the folder where I need to work, clears the screen and tells me what security context I'm in.
"start in directory" command
cmd /K cd C:\WorkSpace
but if WorkSpace happens to be on different than C drive, console will be launched in default folder and then you still need to put D: to change drive
To avoid this use cd with -d parameter
cmd /K cd -d D:\WorkSpace
create a shortcut and your fixed ;)
hi if you want cmd to automatically open when the machine starts up you can place the cmd.exe executable in the startup folder(just search for startup and place a shortcut of cmd.exe there)
regedit worked great. HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\Command Processor, all you have to do is change the AutoRun key value, which is already set to wherever you are currently getting dumped into to a new value in the format of:
cd /d <drive:path>
for c:\, that would be cd /d c:\
for junk, that would be cd d/ c:\junk
its very simple, even a novice thats never used regedit should be able to figure it out. if not, go to the c:\prompt and just type in regedit, then follow the path to the key.

File Access takes me to command prompt rather than Explorer

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 ..

Resources