How to get direct path using Batch File - batch-file

I want to write simple Batch file will click on the batch file
I should go to my directory path should be D:\DS\Install
At present i am doing every 1hr go to
RUN command and typing to cmd and connect to D:\DS\Install
Instead of this I want short cut option.. :-)

If I understand your question correctly,
You want a shortcut on desktop which will open a command prompt and change directory to D:\DS\Install
This is pretty straight forward:
Go to C:\windows\system32 and copy cmd.exe to D:\DS\Install folder
Now right click on the cmd.exe in D:\DS\Install folder and send it to desktop create shortcut.
You will have a shortcut on desktop which will take you to the required folder everytime..
Just FYI... cmd.exe will always open from the directory where it is placed.

Just create a shortcut in your desktop, and when asked for the location, type this command
cmd.exe /k "cd /d "d:\ds\install""
This shortcut will call cmd to execute the cd to change the drive/folder and keep the window open to continue working with it.

You can also make a batch file called ds.bat and put it in c:\windows or any other folder that is on the path.
You can then use the WIN+R hotkey and type ds and enter.
#echo off
cd /d "d:\ds\install"
cmd /k

#echo off
cd /d "d:\ds\install"
cmd /k

Related

Run a batch script in another directory than the batch script directory

I have a batch script that I run from the Windows Task Scheduler, the advantage is that the scheduler has the option of "Start in:", this allows me to run the batch script in a totally separate directory.
In the cmd prompt the equivalent would be to open a cmd prompt window in Directory1 and type out the full Directory2/batchscript.bat.
However, I was wondering if there was a way inside my batchscript.bat to set the directory to "run" in?
Try something like this:
set "your_dir=path_to_your_directory"
pushd %cd%
cd %your_dir%
run_your_command
popd

Starting a batch file from another batch file only opens CMD

When I start a batch file from another batch file, it just opens a new CMD window named just "TEST.bat", and doesn't run the actual batch. Running it manually works fine.
cd %~dp0\Colours\TEST.bat
start "TEST.bat"
I have tried many different ways to run the batch, but it all does the same thing. I've also tried to run the batch as administrator but same result again.
Full code(not finished): http://pastebin.com/GE8yJP0J
To run another batch file, use call not start. Also: cd expects a directory, not a filename.
cd "%~dp0\Colours"
call TEST.bat

how to run application which has .lnk extension with .bat script

how to run application which has .lnk extension with .bat script?
(I have an application and short of that is .lnk extension and want to run it using .bat)
error is that its not running
A file with .lnk extension is just a shortcut to a file.
To launch the executable that the shortcut targets to, just write the shortcut filename in the same way as you will do to run a executable file, as follows:
#Echo OFF
"C:\path yo tour shortcut.lnk"
Exit
Or also:
#Echo OFF
Start /Wait "" "C:\path yo tour shortcut.lnk"
Exit
I know I'm kinda late, but for anyone coming here:
If the shortcut is on the desktop, check whether it is on "your" desktop or on the public one - in batch you access the public one through %public%\Desktop
If you want to run multiple links, use this: start /b \your\path
dont forget the quotation marks if the path has spaces in it!

how to run cmd from batch file and go to folder within parent folder

I have to create a batch file as below
1) It will run cmd
2) then withing that command prompt goes back to parent folder may be with cd..
3) then go to folder jar may with cd jar
4) run command java -jar TASKApi.jar
and this command prompt should remain open
currently I am using below code
start cmd.exe /k cd..
cd jar
java -jar TASKApi.jar
But only first line works other two line does not
Please tell me how can I do this
Edited after a comment below:
:: two.bat
#echo off
cd /d "c:\folder\jar"
java -jar "TASKApi.jar"
To keep the console window open for further input, launch the batch file above from another batch file.
:: one.bat
#echo off
cmd /k call two.bat

In BAT file, how do I move a shortcut?

I have the following line in a BAT file, it does not work, how do I make it work? The shortcut is in the same directory as the BAT file, I have to move it to the desktop.
MOVE "MyShortCut.Ink" C:\
shortcut files have a .LNK extension ("LINK"). You've got INK as in "my pen broke and spilled ink all over my shirt".
In Windows, C:\ is not the the desktop. C:\Users\[Username]\Desktop is usually what you're looking for.
There is an environment variable for C:\Users\[Username] for the currently logged in user which is %USERPROFILE%.
If your running it from another directory, switch to the bat files executing path first;
CD %~dp0
MOVE "MyShortCut.Lnk" "%USERPROFILE%\Desktop"

Resources