Jump to content

Command line switches with run


Recommended Posts

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

Link to comment
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.

Link to comment
Share on other sites

  • Developers

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

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

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.

Link to comment
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

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