ajenkins Posted January 19, 2014 Posted January 19, 2014 I am writing a script that sends a command to cmd.exe and I need the function %~n which gives the file name of the variable (a) then I change the extension of the file. The problem is that when autoit sends the function %~n it becomes %ñ in cmd.exe. I get this when typing if I go from ~ to n without hitting space. so I placed this into my autoit script "%~ n". This works with my pc, but when ran from other computers the function fails and resulting output from my scripted program is "%~ na.txt" instead of the desired "input_filename.txt". Since this script is intended for batch processing it doesn't get past the first file processed. Thanks in advance for any help!
Solution orbs Posted January 19, 2014 Solution Posted January 19, 2014 suggestion #1: make sure you have Command Extensions enabled and Delayed Environment Variable Expansion disabled look here for help: http://ss64.com/nt/setlocal.html suggestion #2: write the entire operation in AutoIt. i doubt there's anything DOS can do and AutoIt can't, and that will make a more stable and coherent script, easier to track and troubleshoot. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates WinPose - simultaneous fluent move and resize Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Magic Math - a math puzzle Demos: Title Bar Menu - click the window title to pop-up a menu
ajenkins Posted January 19, 2014 Author Posted January 19, 2014 Thank you for the suggestions orbs. But my Delayed Environment Variable Expansion are set and working, all work flawlessly in bat. I was hoping to script the entire thing in autoit syntax, but couldn't find help on interacting with an embedded cli program without calling cmd.
michaelslamet Posted January 19, 2014 Posted January 19, 2014 I agree with orbs. Instead of sending chars to command prompt window, it's much more reliable if you convert the bat file to AutoIT. Maybe you could post your batch file and I believe somebody here will glad to help
ajenkins Posted January 19, 2014 Author Posted January 19, 2014 I thank both of you for your replies! I will take your advice and break it all down to autoit. I feel that you are correct and that in the end, the finished product will be worth the extra effort.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now