am i set an icon to shortcut with mklink cmd command - windows

i use on command line on windows and write this.
mklink /D programName c:\program files\my app\program.exe
but i did not set any icon to my shortcut.
how do i do this?

mklink creates a link, not a shortcut.
If you want to create a shortcut from a batch file, you have several options, see creating a shortcut for a exe from a batch file

no, i found xxmklink.exe program after that. I am sorry.
http://www.xxcopy.com/xxcopy38.htm
this is my choice.

Related

how to create a cmd shortcut to a project directory

I want to be able to open cmd and the do :cd project and this will put be in this directory>
C:\Users\USER\AppData\Local\Programs\Python\Python310\Projects\Random_shi\NWT
I know its possible because I saw someone in a youtube video do it once but I couldn't find anything online.
Any help would be appreciated.
Thank you
Using a DOSKEY shortcut works great
doskey shortcut=cd /d PATH
replace shortcut with whatever you want to use to navigate to your folder and PATH with the path to your directory
Example
doskey NWT=cd /d C:\Users\USER\AppData\Local\Programs\Python\Python310\Projects\Random_shi\NWT
Then all you have to do is call
C:\Users\USER>NWT

Context menu for windows bash admin

I would like to be able to open the windows bash terminal from windows explorer with a context menu. Much like you can do in Ubuntu. I have created a subkey in the HKEY_CLASSES_ROOT/Directory/Background/shell with the command:
powershell -c start -verb runas cmd '/c start /D "%V" bash.exe'
This works well for opening the bash as admin in most directories, but it crashes if the directory has a space in it. It seems to be that bash only takes part of the string, and then can't find the directory to navigate to. I've tried escape quotes around the %V, e.g """%V""" but that didn't help. Any ideas?
Here's an alternate approach that avoids PowerShell. Create a key named "HKLM\Software\Classes\Directory\background\shell\runas" and give it a default value like "Open in bash as administrator". Create a subkey named "command" and give it a default value of "C:\Windows\System32\cmd.exe" /c start /B /D "%V" bash.exe. Change the path to cmd.exe if you have a different system directory. It has to be the fully-qualified path to cmd.exe. – eryksun

How can I create a shortcut to launch a batch file one folder up?

I have been trying to create a shortcut to launch a batch file one folder up from the shortcut location.
I have been able to do this using and intermediate batch file in the same folder as the shortcut as follows:
Intermediate.bat:
#echo off
FOR %%V IN ("%~dp0..\") DO set curdrv=%%~dpV
start "" %curdrv%Oneup.bat
And the shortcut target is:
%windir%\system32\cmd.exe /c Intermediate.bat
and the 'Start in' is left blank.
This way I can move these folders anywhere on the drive or another drive and the shortcut still works.
However, I would like to leave out the Intermediate.bat file and launch the Oneup.bat directly. I tried:
%windir%\system32\cmd.exe /c FOR %%V IN ("%~dp0..\") DO set curdrv=%%~dpV && start "" %curdrv%Oneup.bat
in the Target of the shortcut, but it doesn't work.
Is there some trick to getting this to work?
Thanks
I think I found the answer:
%windir%\system32\cmd.exe /c start "" "..\Oneup.bat"
This is placed in the shortcut target with start in being left empty.

Delete a shortcut using "erase" or "del" commands in cmd.exe

When I try to delete folder shortcuts from command prompt it deletes the target folder contents.
Can anyone help me to find another way to just delete shortcut?
Thanks to Christian K. I found the answer:
First I created a .lnk file (shortcut) with mklink but when I used del or erase to delete shortcut target file contents deleted. So now we can use rmdir to remove just shortcut.

Windows 7: cmd.exe: setting startup directory (in a link to cmd.exe)

I am running Windows 7 and when I run cmd.exe I want it to start up
in a directory named C:\foo\bar. I remember being able to create a
link to this executable on the desktop and right clicking somewhere
to set the startup menu of the cmd.exe command prompt by filling
out a field in a transient window, but I cannot find it. I have
found the following argument which however seems more complicated.
I want to set the startup directory for cmd.exe via a popup window.
Changing default startup directory for command prompt in Windows 7
Any ideas?
as mentioned by the other posters already:
the regular approach is to edit the shortcut's properties and fill the field labled "start in". simple as that.
however, for some reason this has no effect on UAC enabled systems if at the same time you also enable the "run as administrator" checkbox in the advanced properties of the shortcut.
a solution is to put everything in the "target" field of the shortcut:
%windir%\System32\cmd.exe /K cd /d "E:\My Folder" & sometest.bat
when running on 64bit and you want to explicitly start the 32bit flavour of the command prompt:
%windir%\SysWOW64\cmd.exe /K cd /d "E:\My Folder" & sometest.bat
for additional information on the command line parameters used above see:
cmd.exe /?
cd.exe /?
When you create a shortcut to cmd.exe, you can open the shortcut properties and find under Shortcut tab the Starts in option that will tell cmd.exe where to start, like here:
Open the properties of a shortcut to cmd and set the directory there:
Try this Shortcut Target:
C:\Windows\System32\cmd.exe cd /d %~dp0
Which will start cmd.exe in the shortcut's folder.

Resources