 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
muse
Joined: 01 Jun 2006 Posts: 14
|
Posted: Tue May 13, 2008 1:33 am Post subject: tricky string escape |
|
|
say, I have following content on clipboard:
| Code: | | HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe |
and I need to pass this to a console program as-is (without expanding the %SystemRoot% environment variable). I'm testing this will following code:
| Code: | | Run, cmd.exe /k echo "%clipboard%" |
this will show
| Code: | | "HKEY_CURRENT_USER\Console\C:\WINDOWS_system32_cmd.exe" |
If I replace the string first:
| Code: | | stringreplace, rp, clipboard, `%, `%`%, A |
Then it shows:
| Code: | | "HKEY_CURRENT_USER\Console\%C:\WINDOWS%_system32_cmd.exe" |
The thing is dos command needs double % to escape it, while AHK needs `% to escape it; and I'm not sure how to do escape this here.
Thanks. |
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 770 Location: London, UK
|
Posted: Tue May 13, 2008 2:25 am Post subject: |
|
|
| Code: | #NoEnv
stringreplace, rp, clipboard, `%, ^`%, A
Run, cmd.exe /k echo %rp% |
_________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
muse
Joined: 01 Jun 2006 Posts: 14
|
Posted: Tue May 13, 2008 9:56 am Post subject: |
|
|
Thanks!
I'm quite new to ahk and wasn't aware of #NoEnv.
Also, to enclose in quotes, I need to put ^ before quotes too:
| Code: | | Run, cmd.exe, /k echo ^"%rp%^" |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|