AutoIt RunWait calls command which includes single quotes

CatOnRug solve, automate, speed up AutoIt RunWait calls command which includes single quotes
Tolal success story :)

When i open windows command prompt and type @echo off & cls i get total blank screen

if i run
for /f "tokens=1 delims=:" %i in ("ipconfig") do echo %i
i get nothing, but only ipconfig in output. This example is not a batch file. This is code pasted directly in command prompt. If use batch files then %i should be replaced with %%i.

In previous example if i replace "ipconfig" with 'ipconfig' the system will actually launch the command and replace the array of for with ipconfig's output.
Next the tokens=1 delims=: split the output in two pieces and take the one whitch is in left side before :.
for /f "tokens=1 delims=:" %i in ('ipconfig') do echo %i

The point is thant in single quotes for in do function actually call the command so if we need to call command we have stick to the single quotes. Not double.

If we want to use this code in AutoIt command we have to replace ' with '&chr(39)&' that actually breaks the string and appends single quote character.

Here is final example how it works.
RunWait(@ComSpec & ' /c ' & '@echo off & (for /f "tokens=1 delims=:" %i in ('&chr(39)&'ipconfig'&chr(39)&') do echo %i) & pause', '', @SW_SHOW)
Here is example how to compile AutoIt (au3) application

By learning this now i am able to add GUI in my
List locally installed printers on remote machine.


No comments:

Post a Comment