Jump to content

run script from command line


Recommended Posts

autoit3 under Win7 (x64)

Here's a very simple script that reports the number
of parameters it's called with:

cmd_line_nparm.au3
$nparm = $CmdLine[0] ; number of parameters
MsgBox(0,"","nparm: " & $nparm)

If I start a dos session and cd to the folder where
this file is stored and run

cmd_line_nparm.au3 abc def

the response is nparm: 0 ; but if I provide the full
path to the autoit exe file    I get the correct answer (2).

Can anyone tell me what I need to do to avoid having to
provide the full path? (Hopefully without needing to
re-install autoit3)

Thanks!

Link to comment
Share on other sites

Doesn't help, and I don't see why it should: the problem isn't that the autoit exe isn't being found --- it is, even with out specifying the full path. In both cases the MsgBox window pops up, so clearly the script is being executed. The problem is that without the full path, the command-line arguments apparently aren't being seen.

Link to comment
Share on other sites

How are you able to run a script from the command line without it being compiled, or specifying the autoit3.exe program to run it?

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

Looks like you have testing to do and maybe file a bug. Don’t expect much if you are not willing to dive in and work. You need to create testable scripts we can also test at least

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

  • Developers
1 minute ago, Earthshine said:

Looks like you have testing to do and maybe file a bug

Meaning what exactly ..bugwise? 

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

Just trying to understand how this ever would be a bug?

Only thing I can imagine is that the registry setting for "Open" for fileextension .au3 doesn't pass the arguments, but can't see how this would be something wrong in autoit3.
For me it's working fine so a wild guess: Somebody selected "Open With" and "always use" and created a registry entry which isn't correct.

SciTEConfig can display the current settings for AutoIt3 so show me that output to check it. (Other tools/RunAutoIt3/SciTE check)

 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

  • Developers

Well, try what was posted and it works fine for me when I have Open set to Run in stead of Edit.

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

Working fine here also. For the exe anyway. Gotta take a look at the au3.

@Jos: ".. it works fine for me when I have Open set to Run in stead of Edit"

How do you change it? Do i have to change in registry? ATM it's set to edit.

In registry:

"C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe" "%1"

 

 

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • Developers
6 minutes ago, careca said:

@Jos: ".. it works fine for me when I have Open set to Run in stead of Edit"

How do you change it? Do i have to change in registry? ATM it's set to edit.

SciTEConfig is your friend. ;)
Tab "General 1" the very first option.

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

Thanks, but something weird happened, the tool was already set to run, i changed it to edit, and to run, couple of times while checking the registry, nothing changed, maybe i messed something up in registry, i always import my modified registry when i install windows, so that must be it. But shouldn't the config tool override anything i may have done in the registry? It showed green as a successfull change.

Anyway doesn't matter, this is what works:

"C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe" "C:\Users\careca\Desktop\123.au3" "abc"

Or if i change in registry the key au3file

"C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe" "%1"

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • Developers

Simply do the check with SciTEConfig as well:

This when you select Run:

Quote

******************************************************************************************************************************************
* HKCR\.au3 Default       :AutoIt3ScriptBeta
* HKCR\.au3 ShellNew      :C:\WINDOWS\SHELLNEW\Template.au3 (File Exists)
******************************************************************************************************************************************
* Explorer shell options:
* HKCR\AutoIt3ScriptBeta\shell: 
*  => Default Action:Run

*     Compile                => Command:"C:\Program Files (x86)\AutoIt3\Beta\Aut2Exe\Aut2Exe.exe" /in "%l"
*     Compile with Options   => Command:"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /ShowGui /in "%l"
*     CompileX64             => Command:"C:\Program Files (x86)\AutoIt3\Beta\Aut2Exe\Aut2Exe_x64.exe" /in "%l"
*     CompileX86             => Command:"C:\Program Files (x86)\AutoIt3\Beta\Aut2Exe\Aut2Exe.exe" /in "%l"
*     Edit                   => Command:"C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe" "%1"
*     Open                   => Command:"C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe" "%1"
*     Run                    => Command:"C:\Program Files (x86)\AutoIt3\Beta\AutoIt3.exe" "%1" %*
*     RunX64                 => Command:"C:\Program Files (x86)\AutoIt3\Beta\AutoIt3_x64.exe" "%1" %*
*     RunX86                 => Command:"C:\Program Files (x86)\AutoIt3\Beta\AutoIt3.exe" "%1" %*
******************************************************************************************************************************************

This changes when you select Edit:

Quote

* Explorer shell options:
* HKCR\AutoIt3ScriptBeta\shell: 
*  => Default Action:Open

Show me your info generated by SciTEConfig when you need help.

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
11 minutes ago, Earthshine said:

Here’s how to fix it, delete that whole damn key and then reinstall autoit and the editor

Please stop making these kind of suggestions without being explicit please! ;)

I have clearly explained the OP (or others for that matter) what the appropriate steps are and am convinced it will work when you do them.
Where did it go wrong for you as I haven't seen you posting the results here from this step:

On 22-12-2017 at 7:04 PM, Jos said:

SciTEConfig can display the current settings for AutoIt3 so show me that output to check it. (Other tools/RunAutoIt3/SciTE check)

This report indeed will suggest to remove a key from the registry in case a manual override was done.

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 layed out all correctly, no need to delete keys, or to reinstall, just need to navigate to the .au3 key and see what's in default, should be AutoIt3ScriptBeta

Then navigate to AutoIt3ScriptBeta shell, open, command, and in default: "C:\Program Files (x86)\AutoIt3\Beta\AutoIt3.exe" "%1" %*

Done, scripts run instead of edit. In my case, it didn't work because my key isn't AutoIt3ScriptBeta but au3file. As soon as i changed the command in au3file to the above, it works.

But i get what you mean, you delete the corresponding key for the filetype, and when you re-install, it sets everything back. I guess.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • Developers
On 22-12-2017 at 7:04 PM, Jos said:

For me it's working fine so a wild guess: Somebody selected "Open With" and "always use" and created a registry entry which isn't correct.

This wild guess is not as wild as I stated! This is a pretty common issue for many.  :)

So please let's wait for the OP to come back and read through all these replies in the hope he will see mine and does what should be done in this case:
Simply run SciTEConfig  select tools/RunAutoIt3/SciTE check and post the result or do as suggested which is to delete a Registry key in case somebody has done the "Open with" thing.

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

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

×
×
  • Create New...