Jump to content

AutoIt Running CMD (quote problems)


 Share

Recommended Posts

I have the fallowing line in my script

$s_PID = Run('cmd.exe /k "' & @ScriptDir & '\cmdfiletorun.exe" "' & @ScriptDir & '\' &  $s_File & '"');, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

The commented code is simply to view the cmd window and debug

th eprobelm is wit the quotes around the first @ScriptDir (and possibly the second) when the command prompt starts it simply says

'E:\ is not a reconized...

The way the coding should show if I read it correctly is

cmd.exe /k "E:\My Folder With Spaces\cmdfiletorun" "E:My Folder With Spaces\file being called from first file"

anyone know where my quotes got mixed up?

Link to comment
Share on other sites

I have the fallowing line in my script

$s_PID = Run('cmd.exe /k "' & @ScriptDir & '\cmdfiletorun.exe" "' & @ScriptDir & '\' &  $s_File & '"');, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

The commented code is simply to view the cmd window and debug

th eprobelm is wit the quotes around the first @ScriptDir (and possibly the second) when the command prompt starts it simply says

'E:\ is not a reconized...

The way the coding should show if I read it correctly is

cmd.exe /k "E:\My Folder With Spaces\cmdfiletorun" "E:My Folder With Spaces\file being called from first file"

anyone know where my quotes got mixed up?

When dealing with a convoluted series of quotes, I usually use Chr(34) if the doublequote needs to be part of my string:

$s_PID = Run("cmd.exe /k " &Chr(34) &@ScriptDir & "\cmdfiletorun.exe" &Chr(34) &" " &Chr(34) &@ScriptDir & "\" &$s_File &Chr(34))

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

StringFormat can make things a lot more readable too:

Run(StringFormat('cmd.exe /k "%s\cmdfiletorun.exe" "%s\%s"', @ScriptDir, @ScriptDir, $s_File))oÝ÷ Ûú®¢×¡ë'ßÛm«gyçm¡·ºÚ"µÍ[Ý[ÑÜX]
    ÌÎNØÛY^HÚÈ    ][ÝÉÉÌLÉÌLØÛY[]Ü[^I][ÝÈ  ][ÝÉÉÌLÉÌLÉÉ][ÝÉÌÎNËØÜØÜ   ÌÍÜ×Ñ[JJ
?

My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!
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...