Sign in to follow this  
Followers 0
ajenkins

Sending command to cmd.exe with ~

5 posts in this topic

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!

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0