Sign in to follow this  
Followers 0
redndahead

Command line switches with run

9 posts in this topic

I am trying to run a program. When you go to the shortcut and look at it's path it looks like this.

Z:\TLCS\PROGRAMS\LOGIN\SB4S.EXE Management;Login;Student

What I want to do is run my script with the command line option so it would look like this.

C:\myscript.au3 "Z:\TLCS\PROGRAMS\LOGIN\SB4S.EXE Management;Login;Student"

If my script is like this it doesn't run right:

run($CmdLine[1])
exit

But clicking on the shortcut is ok

Any ideas....

red

Share this post


Link to post
Share on other sites



if you run it like this:

C:\myscript.au3 "Z:\TLCS\PROGRAMS\LOGIN\SB4S.EXE Management;Login;Student"

$CmdLine[0]=2

$CmdLine[1]=Z:\TLCS\PROGRAMS\LOGIN\SB4S.EXE

$CmdLine[2]=Management;Login;Student

so try

if $CmdLine[0]=2 then run($CmdLine[1]& " "&$CmdLine[2])
if $CmdLine[0]=1 then run($CmdLine[1])

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

well that doesn't work.... it looks like if i use any other switch it is ok as is. So is there a problem with having semicolons ";" ?

red

Share this post


Link to post
Share on other sites

Sorry guys...I found out what it was. The program used a completely different working directory than where the executable was in... Just a big pain in the butt.

:whistle:

red

Share this post


Link to post
Share on other sites

could you try it this way?

$tc = ''

for $x = 1 to $CmdLine[0]$tc = $tc & ' ' & $CmdLine[$x]

next

$tc = $tc & ''

run(@comspec & " /c " & $tc)

exit


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I think your problem is the spaces.

Command Lines are usually seperated with spaces, which is why they need to be in Quotes.

run your link

C:\myscript.au3 "Z:\TLCS\PROGRAMS\LOGIN\SB4S.EXE Management;Login;Student"

code to test

;C:\myscript.au3
$x="Z:\TLCS\PROGRAMS\LOGIN\SB4S.EXE Management;Login;Student"
if $CmdLine[0]=2 then $y=$CmdLine[1]&" "&$CmdLine[2]
if $CmdLine[0]=1 then $y=$CmdLine[1]
msgbox(1,"Do these match?,$x & @crlf & $y)
;run("Z:\TLCS\PROGRAMS\LOGIN\SB4S.EXE Management;Login;Student")
;run($y)

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Errr uh thanks guys for the reply but I posted before.... Well maybe you haven't seen it yet. That it was only that that certain program used a completely different working dir.

But thanks for all the suggestions. :whistle:

red

Share this post


Link to post
Share on other sites

Yea, we all type slow I guess, nice to see three responces in one minute though :whistle:


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Dang I didn't recognize that it was all in one minute. Pretty nice :whistle:

Share this post


Link to post
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
Sign in to follow this  
Followers 0