Jump to content

Sending command to cmd.exe with ~


 Share

Go to solution Solved by orbs,

Recommended Posts

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!

Link to comment
Share on other sites

  • Solution

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

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

 

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...