Command line: "-" converted to "û" - windows

I'm running this command in a .bat or .cmd file to launch an ftp script:
ftp –v –i –s:test_script.txt
Command window converts it to this:
ftp ûv ûi ûs:test_script.txt
And thus it does not work.
Note: if I manually run the above command from a cmd window, it works fine. Only fails when I launch it as a .bat or .cmd file.
Need help preventing the conversion. Thanks.

The dashes you have in the command you've provided are ASCII 150, but the dashes used in switches to commands are ASCII 45. I would guess you have copy/pasted this command from a Word doc or email where the editor "helpfully" changed the dashes to em-dashes.
If you copy/paste your command from this question into a cmd window, it won't run properly because of the wrong dashes. Are you retyping it at the command line, perhaps, rather than copy/pasting?
Regardless, the solution is to retype the dashes in your batch file.

Related

How to Work with filenames containing emojis in a Windows Command Prompt or batch script

I am running a Windows batch script. When it encounters a filename that contains an emoji the script balks.
can't open input file `??.mp3': Invalid argument
I have tried setting the code page to Unicode, but it doesn't help.
chcp 65001
If I execute the dir command in a cmd.exe window, the emoji shows as a box. How can I support emojis in a Command Prompt window or batch script?

Run selected line in notepad++ console

This might seem a bit too obvious but I am stuck with it anyway.
I am editing an ffmpeg code in notepad++ and I want to run the selected line of code directly in notepad++ console (nppexec plugin console).
say, I have four lines of code, and I want to run only the second line (selected line):
currently, I am coping the line and pasting it in the console and hitting enter. I know it is very noobie!
Please help to achieve this with a shortcut or something.
Once I created a small nppexex script, to run an external command on the selection, based on that you can use a nppexec script like:
sel_saveto c:\Temp\NPP_Selection.bat
cmd /c c:\Temp\NPP_Selection.bat
Please save your file with the ffmpeg command with ansi encoding (with UTF8 there was an error with some strange characters at the start of the selection).
The script stores the selection in a bat file and then runs it with cmd /c

Problems Executing Powershell from .cmd file

I am attempting to run a build task from a .cmd file where Powershell extracts a zip file, which helps bypass a problem with Visual Studio's limit on the number of directory characters. However, I am having problems getting the Powershell command to execute correctly. I've tried a number of variations with the quotations, and I either get a termination error, or the Powershell command outputs as a string with the zip file not extracted. Below is an example of my current .cmd file:
//%1% is a passed in command line argument for the absolute path, e.g. C:\path\to\dir
set Source=%1%directory.zip
set Destination=%1%directory
powershell -Command $pscmd = '{Add-Type -assembly "system.io.compression.filesystem";[io.compression.zipfile]::ExtractToDirectory("%Source%", "%Destination%");}'; Write-Host $pscmd;
I'm very open to a number of variations that can get this to work, provided that this task runs on the command line, uses Powershell, and can be executed from a .cmd file, which is triggered by our app's build process. I'll be happy to provide additional information if needed. Thanks!
This was a strange one. Your code above has some sort of hidden character in it. I took the code and opened it in notepad, saved as ANSI, and when you type it to command line or open it again in a new instance of notepad you can see the error.
Neither add-type nor ExtractToDirectory give output, so I removed your pscmd var.
I would open your existing script, save as ansi as a new file name, delete the original, rename the new one back to the original name.
Here is what I came up with to troubleshoot your script, and it works on my machine.
I named my script L:\util\unzip.cmd
setlocal
//%1% is a passed in command line argument for the absolute path, e.g. C:\path\to\dir
set _Source='%1\directory.zip'
set _Destination='%1\directory'
echo _Source=%_Source%
echo _Destination=%_Destination%
set _c1=Add-Type -assembly system.io.compression.filesystem;
set _c2=[io.compression.zipfile]::ExtractToDirectory(%_Source%, %_Destination%)
echo _c1=%_c1%
echo _c2=%_c2%
set _Command=^& {%_c1% %_c2%};
: to echo, use double quotes or cmd thinks text after & is another command
echo _Command="%_Command%"
pause
powershell -Command "%_Command%"
endlocal
I ran it like this, and it worked: unzip.cmd L:\util
I'll bet this this info, you are good to go.

How to call an executable file directly in notepad++?

In windows,I use the Notepad++ to write tex file, in the "run..." dialog,I input that:
cmd /k D:\CTEX\MiKTeX\miktex\bin\xelatex $(FULL_CURRENT_PATH)
then run it,however the result shows that 'xdvipdfmx' is not an executable file. But I am sure that I have add its path to the system environment variable,and when I direct run it in the terminal, it's ok.
So,I want to know what I should do to run it in the notepad++ correctly.
Try these improvements:
enclose paths into quotes to avoid problems with spaces
add .exe to executable file name
test the full command in command prompt to see if it works (replace $(FULL_CURRENT_PATH)) with actual file name
please let me know the result
Your example after changes:
cmd /k "D:\CTEX\MiKTeX\miktex\bin\xelatex.exe" "$(FULL_CURRENT_PATH)"
Test it in command prompt like:
cmd /k "D:\CTEX\MiKTeX\miktex\bin\xelatex.exe" "D:\Data\MyDoc1.tex"

Run an input file using an exe file with cmd

I am using Windows 7
How can i run an input file (text file of commands) in an exe progam in CMD please.
Using other questions on the site, i have tried:
CMD /c ""C:/Program Files/Mplus/Mpluswin.exe" "C:/Users/jj/Desktop/mplus/test_mplus.inp""
which opens the input file in the program but does not run it
and this, which opens the program, but not the script
CMD /c "C:/Program Files/Mplus/Mpluswin.exe" < "C:/Users/jj/Desktop/mplus/test_mplus.inp"
Does this depend on the exe program?
Edit:
At present, the first command above launches the exe program and opens the text file within it (this is a file of program specific commands that will read in data, run calculations and output automatically). I can then run the commands in the exe program that has been opened (by selecting run in a menu) . But, I would like to pass the file to the exe program and it to be run automatically, ideally in the background. I am not sure of the correct terminology to use, so sorry if my description is unclear.
I've just noticed that you enclosed the entire term in an extra set of double quotes, and used linux forward slashes - try this batch file and also see if there is any error message on the console.
#echo off
cd /d "%userprofile%\Desktop\mplus"
"C:\Program Files\Mplus\Mpluswin.exe" "test_mplus.inp"
echo mplus was launched
pause

Resources