Mean: I want to add a batch file to the right click property.
Action that this file needs to do is to go to a folder and look up the highlighted/selected text that I've selected when clicking on the batch file.
My question is how to get this highlighted text selected into a variable in the batch file?
Later on I can use this variable in the code to navigate to the folder and select the correct file.
I'll use following code then:
#echo off
start wgnplot.exe "c:\path to file to open\VARIABLE.pdf"
Related
When I use the standard command prompt in Windows and run a bat file (or a bat file that runs a second one) the title bar in the console window changes to the name of the script being run. While I can set the title to anything I want using the TITLE command, that's overriden when running a bat file.
Without modifing the called bat file, how can I preserve the previous title and avoid the change?
Edit
As for why would I want this, let's suppose I have a bat file which sets the console title (for ease of identification) and in turn calls another bat file. During that second bat file execution, the title is lost.
#ECHO OFF
TITLE My bat file is running
REM Some commands run here, custom title is OK
REM Here title is lost and replaced by "AnotherFile"
CALL AnotherFile.bat
REM When the call returns, my custom title returns here
REM More commands with my title again
Question is, how can I preserve the title during the CALL?
Is it possible with a batch file to open a file then execute or "click" an option in the opened application "File" menu with just one .bat file?
So for example normally I would double-click the Firefox shortcut on my desktop then click on "File" > "New Tab".
Is it possible to do that with a single .bat file?
You can use the CursorPos.exe by #Aacini to move the cursor. Here is the download link: https://www.dostips.com/forum/viewtopic.php?t=3428. In the download page, you can only download the set of .exe files. Extract CursorPos.exe from them.
Usage:
CursorPos [[±]col [±]row]
If no parameter is given, return current cursor position as col+(row<<16) in ERRORLEVEL.
If any coordinate have sign, the position given is relative to the current one.
If cursor is moved, the Ascii code of the character at new position is returned in ERRORLEVEL.
And for mouse input you can use batbox.exe. Download link: https://batchprogrammers.blogspot.com/2016/06/batbox-awesome-batch-plugin-by.html?m=1. The full information is available there.
So what i'm trying to do is get a selected file from File explorer, and copy it then paste it into a new folder via a batch file upon clicking it....is there a way?
One way I can think about you doing that is by creating a some sort of data base thing
For Example
#echo off
:fileSelect
echo Which folder do you want?
set /p folderName=
goto %folderName%
You can do it that way. Then you will have to manually put in the locations the files like so
:"Files Name here"
copy C:\"Files location" C:\"Designated location to paste file"
goto fileSelect
That's one simple way of doing it. If that's not exactly what you want or if its unclear let me know and I will attempt to help you find another way to do it.
Is it possible to copy the first sub-folder-name in a main-folder to clipboard and set this sub-folder-name for a .jpg ?
Example:
C:\Users\Admin\main-folder
sub-Folder-name1
subFolder-name2
subFolder-name3
I want that everytime the batch run only the name of the first sub-folder get copied (sub-Folder1) and set this name for a .jpg in another folder with an additional name.
Example Output:
sub-Folder-name1 + _GranCanaria +.jpg
the file will then be called at the end sub-Folder-name1_GranCanaria.jpg
I invoke a batch file from my own extension file type.In batch file i will show the details of invoking file. I know by passing parameters when invokation we will pass it and we will get by "%~sn1" OR "%1" OR "%~nx1". But i need without passing parameters.
Sample Example
My batch file code looks like this(main.bat)
#ECHO on
set modelname=(here i want help)
java -Djava.library.path="C:\Program Files\Internet Explorer" -Xms1024m -Xmx1024m -jar dist/XYZ.jar -models %modelname%
exit
If i click "Kitchen.xyz" then it'll invoke my batch file "main.bat". Now i want set "modelname" as "Kitchen.xyz". If i click "LivingRoom.xyz" ,:modelname" set as "LivingRoom.xyz".
Can anyone help please...
Thanks
You will need to change the Windows Registry associated with the file type of .xyz
[HKEY_CLASSES_ROOT\.xyz\shell]
[HKEY_CLASSES_ROOT\.xyz\shell\Name Of Your Command]
#="&Name Of Your Command"
[HKEY_CLASSES_ROOT\.xyz\shell\Name Of Your Command\command]
#="\"C:\\Path\\To\\Your\\Batch\\File\\main.bat\" \"%1\""
Save that text in a .reg file and execute it to apply the registry changes. Then when you right click .xyz files, "Name Of Your Command" will be one of the options and possibly the default option which would run when double clicked.
Then your main.bat still needs to accept one parameter and assign it to modelname.
You could also do that programatically with the REG command, but regardless of which method you use to set things up, something needs to be run to setup each machine you want to do this on.