.bat files?
-
Marco
- Posts: 2354
- Joined: 27 Jun 2011 15:20
Re: .bat files?
Doesn't work here either...
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Don sees all [cit. from viewtopic.php?p=124094#p124094]
-
PeterH
- Posts: 2829
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: .bat files?
Instead of just calling telnet, try to call
c:\windows\sysnative\telnet
(On 64bit calling telnet from native command box works, but calling from command box out of XY (enter ! in Address Bar) does not - until you specify above full path.)
Edit: see WOW64 Redirection in XY help!
c:\windows\sysnative\telnet
(On 64bit calling telnet from native command box works, but calling from command box out of XY (enter ! in Address Bar) does not - until you specify above full path.)
Edit: see WOW64 Redirection in XY help!
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: .bat files?
Instead of editing your batch files, another option would be to set up a PFA (Portable File Association) to always run batch files in the native cmd.exe (though unfortunately if you want to use XY portably on 32 and 64 bit systems this is a bit annoying).
1. Go to Tools > Customize File Associations
2. Click New
3. Enter the following:Now double-clicking a batch file will run in the native command prompt on 64-bit machines.
You might also want to set your Tools > Configuration > Templates > Command Line Interpreter to the same path so that "!" and "!!" from the address bar use the native command prompt.
Don, maybe you could add an XY only %nativewinsysdir% which would return the System32 path on 32-bit Windows and SysNative on 64-bit? That would provide a means of making this a portable solution.
1. Go to Tools > Customize File Associations
2. Click New
3. Enter the following:
Code: Select all
"Run in Native CMD" bat>%windir%\SysNative\cmd.exeYou might also want to set your Tools > Configuration > Templates > Command Line Interpreter to the same path so that "!" and "!!" from the address bar use the native command prompt.
Don, maybe you could add an XY only %nativewinsysdir% which would return the System32 path on 32-bit Windows and SysNative on 64-bit? That would provide a means of making this a portable solution.
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: .bat files?
http://support.microsoft.com/kb/978779/de ---- german, but with pituresSteylor wrote:It says : 'telnet' is not a recognized command.
I'm using Win7 64bit
http://technet.microsoft.com/en-us/libr ... stallVista
To install Telnet Client on Windows 7 or Windows Vista
Click Start, and then click Control Panel.
On the Control Panel Home page, click Programs.
In the Programs and Features section, click Turn Windows features on or off.
If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
In the Windows Features list, select Telnet Client, and then click OK.
HTH?
-
-
Steylor
- Posts: 12
- Joined: 06 Feb 2013 10:10
Re: .bat files?
Very kind, guys!
I tried to modify a .bat with the c:\windows\sysnative\telnet as Peter suggested, and it works.
Fine with that, but of course the second method, suggested by TheQwerty would suits my needs better.
But I can't seem to make it work.
If I add the string to custom file association, when I click on the .bat file it opens in a dos window the directory containing the file but it doesn't execute it.
This one ""You might also want to set your Tools > Configuration > Templates > Command Line Interpreter to the same path so that "!" and "!!" from the address bar use the native command prompt." I'm not sure how to do it.
I put there
c:\windows\SysNative\cmd.exe
But it doesn't seem to change anything, still says "telnet is not a recognized command etc.".
I tried to modify a .bat with the c:\windows\sysnative\telnet as Peter suggested, and it works.
Fine with that, but of course the second method, suggested by TheQwerty would suits my needs better.
But I can't seem to make it work.
If I add the string to custom file association, when I click on the .bat file it opens in a dos window the directory containing the file but it doesn't execute it.
This one ""You might also want to set your Tools > Configuration > Templates > Command Line Interpreter to the same path so that "!" and "!!" from the address bar use the native command prompt." I'm not sure how to do it.
I put there
c:\windows\SysNative\cmd.exe
But it doesn't seem to change anything, still says "telnet is not a recognized command etc.".
-
Steylor
- Posts: 12
- Joined: 06 Feb 2013 10:10
Re: .bat files?
Stefan ,it's not a telnet problem, I've been using these .bat files daily for years, it's only within XYplorer that I can't run them
Stefan wrote:http://support.microsoft.com/kb/978779/de ---- german, but with pituresSteylor wrote:It says : 'telnet' is not a recognized command.
I'm using Win7 64bit
http://technet.microsoft.com/en-us/libr ... stallVistaTo install Telnet Client on Windows 7 or Windows Vista
Click Start, and then click Control Panel.
On the Control Panel Home page, click Programs.
In the Programs and Features section, click Turn Windows features on or off.
If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
In the Windows Features list, select Telnet Client, and then click OK.
HTH?
-
-
PeterH
- Posts: 2829
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: .bat files?
Sorry - TDNHStefan wrote: HTH?
-
(That Did Not Help
Telnet was selected there...
Here the problem is that XY on 64bit windows seems to use 32bit command window. And this uses (for this case) "wrong" \windows\system32\
So you either must force XY to use 64bit command window, or force 32bit command window to use the correct directory for telnet.
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: .bat files?
Steylor wrote:If I add the string to custom file association, when I click on the .bat file it opens in a dos window the directory containing the file but it doesn't execute it.
Ignore the pattern I gave you previously and try this:
Code: Select all
"Run in Native CMD|C:\Windows\SysNative\cmd.exe" bat>::OpenWith("""%windir%\SysNative\cmd.exe"" /C <items>", 'm');"Run in Native CMD|C:\Windows\SysNative\cmd.exe" This defines the caption (before "|") and icon (after "|") to display in the Portable Open Menu (POM). For whatever reason the environment variable doesn't work correctly here. (Don is that a bug?)
bat This is the file extension or matching pattern that you want to change the behavior for.
> Separator between the matching pattern and the actual action.
::OpenWith("""%windir%\SysNative\cmd.exe"" /C <items>", 'm'); This is a script that will open the selected items using a separate command prompt for each one.
So now double-clicking one batch file should work, as will selecting many and hitting Enter, File > Open, or POM > Run in Native CMD.
XYplorer allows you to open a command prompt or execute commands directly from the address bar by using the prefix "!" and "!!". The Template option I pointed you to changes which application XY uses to execute those commands.Steylor wrote:This one ""You might also want to set your Tools > Configuration > Templates > Command Line Interpreter to the same path so that "!" and "!!" from the address bar use the native command prompt." I'm not sure how to do it.
I put there
c:\windows\SysNative\cmd.exe
But it doesn't seem to change anything, still says "telnet is not a recognized command etc.".
If you set it to the SysNative path you can now enter "!telnet" in XY's address bar to open a command prompt and execute telnet (or "!!telnet" to just execute telnet without keeping the command prompt open afterwards).
Hopefully that's a little clearer?
Sorry again that my first post was incorrect!
-
Steylor
- Posts: 12
- Joined: 06 Feb 2013 10:10
Re: .bat files?
BIIINGOOO!
That's it TheQwerty! Now it works!
I don't get all of it (/C <items>", 'm'
?????????) , but I get how it works.
Thx everybody for your help guys!
Very happy I can now use this file manager, the best in my opinion. (Will be the best-est when MTP support will be implemented, but hey, I can live without it!
)
Thx again and bye everyone!
That's it TheQwerty! Now it works!
I don't get all of it (/C <items>", 'm'
Thx everybody for your help guys!
Very happy I can now use this file manager, the best in my opinion. (Will be the best-est when MTP support will be implemented, but hey, I can live without it!
Thx again and bye everyone!
-
admin
- Site Admin
- Posts: 66375
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: .bat files?
Good idea, and yes, there was a bug with icons in PFA menu.TheQwerty wrote:Don, maybe you could add an XY only %nativewinsysdir% which would return the System32 path on 32-bit Windows and SysNative on 64-bit? That would provide a means of making this a portable solution.
Next beta this PFA will work:
Code: Select all
"Run in Native CMD|%winsysnative%\cmd.exe" bat>::OpenWith("""%winsysnative%\cmd.exe"" /C <items>", 'm');FAQ | XY News RSS | XY X
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: .bat files?
We can help demystify this for you.Steylor wrote:I don't get all of it (/C <items>", 'm'?????????) , but I get how it works.
I assume you're okay with the rest of the stuff I had you enter and are just caught up on the script but if I'm wrong please say so.
Breaking this down a little more...TheQwerty wrote:::OpenWith("""%windir%\SysNative\cmd.exe"" /C <items>", 'm'); This is a script that will open the selected items using a separate command prompt for each one.
PFA/POM treat the action part of the pattern as an application that should handle the matched items. The "::" tells XY that instead of an application we want it to execute a script.
In this case our script is one that sacrifices portability for a simple one-line solution that at least corrects things on 64-bit OSes. (Thanks to Don we can soon have our cake and eat it too!) In fact, this script is just a single command OpenWith which "opens the currently selected list item(s) with the specified application."
So OpenWith is a scripting command which accepts three arguments...
- Application: This is required and specifies the application to open the items with. In our case the application is "cmd.exe" but we also have to pass some additional parameters which leads to that crazy quoting.
- Mode: This is optional and defines what should happen when multiple items are selected. 's' stands for 'Single Instance' meaning open all of the items in one instance of the application. 'm' stands for 'Multiple Instaces' meaning for each item open a new instance of the application. What you use depends on what the application accepts as input, in our case we need to launch a new instance for each item, hence 'm'.
- Itemlist: This is optional and specifies the items to open instead of the current list selection. We don't have a need for this here.
Now to understand what we passed in as the application:
Code: Select all
"""%windir%\SysNative\cmd.exe"" /C <items>"Second, to have literal quotes within a string you need to escape them which in XY means doubling them up. What we really mean by the above is
Code: Select all
"%windir%\SysNative\cmd.exe" /C <items>What are those parameters? If you enter "cmd /?" at the command prompt you see all the available options. "/C" tells it to execute the specified command and then close the command prompt. We could also use "/K" which would do the same but leave the command prompt open afterwards.
"<items>" is an XY variable that gets replaced by the path(s) to the current selection from the active list pane when the script gets executed. In other words it is the batch file(s) that we want to open.
So what does all this mean?
If you had selected two batch files: "C:\One.bat" and "C:\Two.bat" when you call this script it is the same as executing the following from the Windows' run dialog:
"%windir%\SysNative\cmd.exe" /C "C:\One.bat"
and
"%windir%\SysNative\cmd.exe" /C "C:\Two.bat"
If we passed 's' in instead of 'm' it would be equivalent to:
"%windir%\SysNative\cmd.exe" /C "C:\One.bat" "C:\Two.bat"
Which would have used the second batch file as an argument within the first one - not at all what you want.
Slightly off-topic: Why the use of double (") and single (') quotes? Double-quotes tell XY to expand variables within the string (such as resolving <items> to the path to the selected items). Single-quotes tells XY to just leave it alone, so '<items>' would be treated as <items> not the actual list selection. Technically, the single-quotes around the 'm' argument are not needed, but I personally prefer to include them.
HTH!
---
Thanks Don! That'll help greatly!
-
Steylor
- Posts: 12
- Joined: 06 Feb 2013 10:10
Re: .bat files?
WOW. You made it crystal-clear!!!!
And it also seemes that this post helped the developement of the software
Thank you again!!!
Stefano
And it also seemes that this post helped the developement of the software
Thank you again!!!
Stefano
-
highend
- Posts: 14956
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: .bat files?
Am I the only one, where two selected .bat files are executed two times (resulting in 4 cmd windows)?"Run in Native CMD|%winsysnative%\cmd.exe" bat>::OpenWith("""%winsysnative%\cmd.exe"" /C <items>", 'm');
Ofc with the newest beta release...
One of my scripts helped you out? Please donate via Paypal
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: .bat files?
With multiple files it depends on how you open it. File > Open Selected Items triggers the script for each file and opens n-squared times.highend wrote:Am I the only one, where two selected .bat files are executed two times (resulting in 4 cmd windows)?"Run in Native CMD|%winsysnative%\cmd.exe" bat>::OpenWith("""%winsysnative%\cmd.exe"" /C <items>", 'm');
Ofc with the newest beta release...
File > Open With... or the POM menu opens each item once.
Of course now we can replace the above with
Code: Select all
"Run in Native CMD|%winsysnative%\cmd.exe" bat>"%winsysnative%\cmd.exe" /CNow File > Open Selected Items and double-click open each item once, but File > Open With... or the POM menu fails because it wants to open one instance with multiple files.
EDIT: I guess we could have used this shorter version all along. Not sure why I dragged us into using an OpenWith script there.
-
highend
- Posts: 14956
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: .bat files?
Mh, it isn't getting easier...
Try to open a bat file with admin rights, that contains the telnet command...
It's not getting redirected to the %winsysnative% folder and fails.
Conclusion: We need a x64 XYplorer version now :-/
Try to open a bat file with admin rights, that contains the telnet command...
It's not getting redirected to the %winsysnative% folder and fails.
Conclusion: We need a x64 XYplorer version now :-/
One of my scripts helped you out? Please donate via Paypal
XYplorer Beta Club