Jump to content

run with @ComSpec not work in some cases


Guest
 Share

Go to solution Solved by Guest,

Recommended Posts

hello,

i do some complex tests about running exe with arguments using @ComSpec.

 

i worte this small function:

Func ComSpecSend($String,$WaitForReturn = 0)
    $DOS = Run(@ComSpec & " /c "&$String, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    If $WaitForReturn = 1 Then
        ProcessWaitClose($DOS)
        Return StdoutRead($DOS)
    EndIf
EndFunc

and i created this exe file for tests:

#include <array.au3>

If $CmdLine[0] > 0 Then
    _ArrayDisplay($CmdLine,"arguments:")
Else
    MsgBox(0,"","no arguments")
EndIf

after that i runned to that exe file with this way:

ComSpecSend('"D:\exe test.exe" "a b cde " fg      " " hikk"')

this test was failed and I do not know why.

when i tryed to open cmd in windows and send this line

"D:exe test.exe" "a b cde " fg      " " hikk"

 

 

then it worked.

so it must be something with @ComSpec and run()

this test:

ComSpecSend('"D:\exe test.exe" arg1 arg2 arg3')

Passed

and this test:

ComSpecSend('"D:\exe test.exe" arg1 arg2 "arg3"')

also failed.

With the normal cmd in windows it worked..

Edited by Guest
Link to comment
Share on other sites

  • Solution

ok i solved the problem.

i was supposed to use ShellExecute ( "filename" [, "parameters")

I did not know well enough that function and i tried to use this function only in this way:

ShellExecute('"D:exe test.exe" parm1 parm2')

and it did not work..

I was supposed to look in the help file to know the function better.

Anyway, I think what I tried in the first post was supposed to work.

so i think that there is a bug that case and maybe to you need to know it

Link to comment
Share on other sites

What failed in the code you posted in the first post, you never explained that? 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

What failed in the code you posted in the first post, you never explained that? 

failed = nothing happened

Edited by Guest
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...