Jump to content
Steinland

Trying to get $CmdLine(1) in Run command

Recommended Posts

Steinland

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?

Share this post


Link to post
Share on other sites
ViciousXUSMC

I would be interested in seeing what you are trying to do, there could be a better way.

My guess is that your running into your standard issue with cmd arguments not handling spaces and such. 

Share this post


Link to post
Share on other sites
Steinland

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

Share this post


Link to post
Share on other sites
Steinland

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

Share this post


Link to post
Share on other sites
Jos

@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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Moonscarlet

@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

Share this post


Link to post
Share on other sites
Jos

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Steinland

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.

Share this post


Link to post
Share on other sites
Moonscarlet

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

Share this post


Link to post
Share on other sites
Jos

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Jos
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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Steinland

If i create program.exe and want a parameter for it,

Lets say "program.exe C:\Longfilename,txt". But the filename is not constant. It's just been created.

Share this post


Link to post
Share on other sites
Moonscarlet

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)

 

Share this post


Link to post
Share on other sites
Steinland

Let me refer it as this. I just downloaded a file and I want to open it with my scripted exe. The browser will run the exe with the file as parameter.

myprogram.exe justdownloadedtemporaryfile.file

Share this post


Link to post
Share on other sites
Steinland

I want to run it from the browser itself.

Share this post


Link to post
Share on other sites
Steinland

DownloadFile.exe C:\Users\Steinland\AppData\Local\Temp\Supergirl.S03E12.1080p.WEB.x264-STRiFE.torrent

Where in the script can I extract the torrent part?

Share this post


Link to post
Share on other sites
Steinland

The script itself:

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

Then some type commands, then some tabs, then enter.

Share this post


Link to post
Share on other sites
Steinland

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])

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

×