Jump to content

Trying to get $CmdLine(1) in Run command


Recommended Posts

I have been trying now to integrate autoit and vbs to create the perfect system for downloading torrents.

But the final step is that I need to run utorrent with the torrentfile as a parameter. From then I can tell autoit what to write and do but there is a problem.

To execute the autoit exe file I need to include what path that will be written into utorrent and I can't get it to work.

The path to where I want to save the torrent is in the parameter but $CmdLine[1] does not work with ShellExecute.

How do I perform the execution of utorrent and passes on the parameter to the execution of utorrent?

Link to comment
Share on other sites

Just trying to execute utorrent with the parameter.

ShellExecute("C:\Program Files (x86)\uTorrent\utorrent.exe " & $CmdLine[1])

Works perfect from run prompt:

C:\Program Files (x86)\uTorrent\utorrent.exe C:\Users\Steinland\AppData\Local\Temp\Supergirl.S03E12.1080p.WEB.x264-STRiFE.torrent

Link to comment
Share on other sites

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Steinland\Dropbox\StartTorrent.au3"    
"C:\Users\Steinland\Dropbox\StartTorrent.au3" (13) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
ShellExecute("C:\Program Files (x86)\uTorrent\utorrent.exe " & $CmdLine[1])
ShellExecute("C:\Program Files (x86)\uTorrent\utorrent.exe " & ^ ERROR
>Exit code: 1    Time: 0.08584

Link to comment
Share on other sites

  • Developers

@Moonscarlet, How does that help?

@Steinland, You are trying to retrieve an commandline parameter which wasn't provided in at the startup, and you are not checking its presence.... hence the error.

How are you planning to provide that filename to the script?

Jos

 

Edited by Jos

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

@Jos

Quote

Just trying to execute utorrent with the parameter.

ShellExecute("C:\Program Files (x86)\uTorrent\utorrent.exe " & $CmdLine[1])

Works perfect from run prompt:

C:\Program Files (x86)\uTorrent\utorrent.exe C:\Users\Steinland\AppData\Local\Temp\Supergirl.S03E12.1080p.WEB.x264-STRiFE.torrent

Isn't it possible to do it using Run() like this?

Run(@ComSpec & " /c " & 'C:\Program Files (x86)\uTorrent\utorrent.exe C:\Users\Steinland\AppData\Local\Temp\Supergirl.S03E12.1080p.WEB.x264-STRiFE.torrent')

 

Edited by Moonscarlet
Link to comment
Share on other sites

  • Developers

The point is that there is an error reffering to the $cmdline array and not and shellexecute issue, so prefer to stay on the issue at hand. ;)

Jos

 

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

What about the command line parameter? How do I extract it? $CmdLine[1] to a string that can be inserted in the run command?

C:\Program Files (x86)\uTorrent\utorrent.exe C:\Users\Steinland\AppData\Local\Temp\Supergirl.S03E12.1080p.WEB.x264-STRiFE.torrent

The bold part is different for every torrent.

Link to comment
Share on other sites

  • Developers

I fully understand what you meant in the initial post but am still puzzled what the purpose of the script is and how you plan to provide that bold filename to the script.
You clearly were testing from within SciTE pressing the Run command and did not provide any parameter for the commandline. 

Also the commandline parameters in shellexecute are provided through a separate parameter  :

ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

Jos

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

  • Developers
1 minute ago, Moonscarlet said:

That's what I mean, since it's different every time, why are you using $CmdLine and not Run() with utorrent path & filepath directly?

Not making too much sense to me... and please use the standard forum colors for posts. :)

Jos

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

Let me try to clarify this again :P

I have a torrent file downloaded "D:\1.torrent" and my Utorrent is located here "C:\Users\moons\AppData\Roaming\uTorrent\uTorrent.exe"

Doing this will open utorrent and add the new torrent to my download list:

$TorrentPath= "D:\1.torrent"
Run(@ComSpec & " /c " & 'C:\Users\moons\AppData\Roaming\uTorrent\uTorrent.exe '&$TorrentPath,"",@SW_HIDE)

 

Link to comment
Share on other sites

I open firefox. I visit my website. I click on a link. I get to choose to open it or save it. I want to open it with DownloadTorrent.exe.

DownloadTorrent.exe will now open and the first parameter will be my downloaded file like some temporary stored .zip and I want to use it in a new run command,

This does not work:

ShellExecute("C:\MySecondFile.exe " & $CmdLine[1])

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