1
I want to automate the process of opening a certain file with a batch script. The idea is that the folder with the batch script and the file will be distributed to other computers and It the script is supposed to start the program(file) inside a CMD window. Now here's the problem. The path of the folder which contains both the file and script is unknown since I don't know where the users will place the folder. I've solved this part of the problem with the following lines in my script.
@echo off
echo %~dp0|clip
pause
Now this copies the path of the file to the clipboard. What i need now is to use the path so i can open the program in the folder. The problem is that I don't know how to automate the process of pasting from clipboard in CMD. My idea is to run something like this:
start cmd /c "action" "pastePathHere\otherFileName"
"action" being what to do with the file.
But i can't figure out a way to do this. I want to make it all happen within one .bat
file for conveniency.
2Forget the clipboard and just use
start cmd /c "action" "%~dp0\otherFileName"
– DavidPostill – 2018-02-10T18:49:39.497@DavidPostill I think i tried something similar but it didn't work. I must've messed up the syntax. This works like a charm thank you. – EnCoder – 2018-02-10T18:56:14.863