Jump to content

syntax .... very simple?


Recommended Posts

  • Developers

Yes, thanks. :whistle: Thats the first line that has worked. I still, because of the position of the second single-quote, don't see how to user a variable for the command.

Now there are problems with quotes again. At least now we KNOW that it can be done. :P Thanks JdeB!

$cmd = 'Run(@COMSPEC & '' /c start "C:\windows\notepad.exe"'')'
Run(@AutoItExe & ' /AutoIt3ExecuteLine "' & $Cmd & '"')

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

if not GUICtrlRead($in_file1) = "" then _send('Run(@COMSPEC & '' /c start "' & GUICtrlRead($in_file1) & '"'',@HOMEDRIVE, @SW_HIDE)')

This works, but only as well as what I had originally.

an error occurs if there is a space in the $Cmd

EDIT:

if not GUICtrlRead($in_file1) = "" then _send('Run(@COMSPEC & '' /c start ""' & GUICtrlRead($in_file1) & '""'',@HOMEDRIVE, @SW_HIDE)')
does not give an error, but seems to be setting the command as a title in cmd. Could someone try it out? Edited by daslick
Link to comment
Share on other sites

I think I finally got the format... I will post back if it fails me, or try stringformat()

$Cmd / the command sent to the server = 'Run(@COMSPEC & '' /c start ' & GUICtrlRead($in_file1) & "'" & ',@HOMEDRIVE, @SW_HIDE)'

Run(@AutoItExe & ' /AutoIt3ExecuteLine "' & $Cmd & '"')

double quotes and spaces appear to be working inside $Cmd :whistle:
Link to comment
Share on other sites

This works, but only as well as what I had originally.

an error occurs if there is a space in the $Cmd

EDIT:

if not GUICtrlRead($in_file1) = "" then _send('Run(@COMSPEC & '' /c start ""' & GUICtrlRead($in_file1) & '""'',@HOMEDRIVE, @SW_HIDE)')
does not give an error, but seems to be setting the command as a title in cmd. Could someone try it out?
If you send code to the command line the spaces could kill you. As an example if you have to send a pathname with a space then the command line will need the double qoutes so a line like C:\My Documents can not be used with 'C:\My Documents' OR "C:\My Documents". It would have to be '"C:\My Documents"'. And before anyone starts jumping I've been aware of FileGetShortName for a long time now. The problem is I've seen (again a few days ago) FileGetShortName fail with Cmd.exe. I've also seen situations where I would have to quote the the first part of a line and then no quotes for the parameters and then Quotes for the last part of the line. In those cases I usually experiment with testing portions of the command line to see where it fails and then work from there. A really good way to fail is to try

$File = @DesktopDir & '\Test.exe

Run(@Comspec & " /c Dir C:\ > " & $File)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks, but $Cmd must have spaces working because it is what the user inputs... I am not presetting $Cmd to the desktop directory, or any other directory. It is whatever command the end-user enters. I will keep your suggestion in mind for next time I am using a macroed (@...) directory.

EDIT: O, and I DID notice that spaces aren't actually working. a command line cmd /c pause works, but if I try to run a file in a directory with a space in it, it doesn't work. I am working on a solution.

EDIT2: FOUND! - I used your suggestion Geosoft, thanks.

if not GUICtrlRead($in_file1) = "" then _send('Run(@COMSPEC & '' /c start ' & FileGetShortName(GUICtrlRead($in_file1)) & "'" & ',@HOMEDRIVE, @SW_HIDE);')
Edited by daslick
Link to comment
Share on other sites

Solution found. Double quotes and spaces appear to be working. :P

if not GUICtrlRead($in_file1) = "" then _send('Run(@COMSPEC & '' /c start ' & "' & FileGetShortName('" & GUICtrlRead($in_file1) & "')" & ',@HOMEDRIVE, @SW_HIDE);')

Thanks for all of your help :whistle:

by the way, my udf "_send" just sends its parameters to the server file in the remote access script I made.

Link to comment
Share on other sites

Solution found. Double quotes and spaces appear to be working. :P

if not GUICtrlRead($in_file1) = "" then _send('Run(@COMSPEC & '' /c start ' & "' & FileGetShortName('" & GUICtrlRead($in_file1) & "')" & ',@HOMEDRIVE, @SW_HIDE);')

Thanks for all of your help :whistle:

by the way, my udf "_send" just sends its parameters to the server file in the remote access script I made.

Glad you got it working.

I only used @DesktopDir as an example. I just didn't feel like typing in a long string but the principal is the same.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...