Jump to content
Sign in to follow this  
Phil Viton

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!

Share this post


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

Share this post


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

Share this post


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

 

Share this post


Link to post
Share on other sites
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.
  :)

Share this post


Link to post
Share on other sites

After all diligent testing, if this is a bug, you guys would direct him to submit. Or am I wrong? I am sure you guys would fix a bug. Maybe not

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

You know more than I do. I don’t have anything to test. I doubt it’s a bug. He should test this on another vm or computer 


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites

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

Share this post


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

Share this post


Link to post
Share on other sites
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.
  :)

Share this post


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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.
  :)

Share this post


Link to post
Share on other sites

m The key to be deleted is under classes->.Au3 I believe.  That’s how I fix that had to just reinstall product. I’m not at the computer at the moment

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


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

Share this post


Link to post
Share on other sites
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.
  :)

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Luigi
      Greetings,
      I need write a command line to run an .exe with parameters, one this parameters is a password with special characters  like:   [ ] \ "  etc.
      The password is write between double cotes too.
      When run this command line, catch error.
      I buid this function, sometimes run ok, others show error.

      Someone can any idea?

      Best ragards
      #include <Array.au3> Global $G_AIX_DEFAULT_PASSWORD = "******" Func Scape_Word_To_MSDOS($var = "") ;~ https://www.robvanderwoude.com/escapechars.php Local $aCharacters[][2] = [ _ ["%", "%%"], _ ["^", "^^"], _ ["&", "^&"], _ ["<", "^<"], _ [">", "^>"], _ ["|", "^|"], _ ["'", "^'"], _ ["`", "^`"], _ [",", "^,"], _ [";", "^;"], _ ["=", "^="], _ ["(", "^("], _ [")", "^)"], _ ["!", "^^!"], _ ["\", "\\"], _ ["[", "\["], _ ["]", "\]"], _ ['"', '\"""'], _ [".", "\."], _ ["*", "\*"], _ ["?", "\?"] _ ] Local $iSearch $var = StringSplit($var, "", $STR_NOCOUNT) Local $iSize = UBound($var, $UBOUND_ROWS) - 1 For $ii = 0 To $iSize $iSearch = _ArraySearch($aCharacters, $var[$ii]) If $iSearch >= 0 Then $var[$ii] = $aCharacters[$iSearch][1] Next Return _ArrayToString($var, "") EndFunc ;==>Scape_Word_To_MSDOS Local $password = "-Dk5iFB2UjOt[-x|""" & "" Local $password_scape = Scape_Word_To_MSDOS($password) ConsoleWrite("[" & $password & "]" & @LF) ConsoleWrite("[" & $password_scape & "]" & @LF)  
       
    • By Burgs
      Greetings,
        I would like to be able to write a script to send commands to the console for creation of Gstreamer pipelines.  I was thinking of something similar to this:
      Local $iPID = Run("C:\Windows\System32\cmd", "", @SW_MAXIMIZE) ;THIS OPENS THE CONSOLE...!!! if $iPID == 0 Then ConsoleWrite(@CRLF & "I DID NOT OPEN CMD...error: " & @error & @CRLF) if $iPID <> 0 Then ConsoleWrite(@CRLF & "I OPENED CMD...!!!" & @CRLF) $hCmd = WinGetHandle("C:\WINDOWS\system32\cmd.exe") if $hCmd <> 0 Then WinActivate($hCmd) ;ensure command console is active... $sOutput = Send("cd C:\gstreamer\1.0\x86_64\bin" & @CRLF, $SEND_RAW) $sOutput = Send("gst-launch-1.0 videotestsrc ! autovideosink" & @CRLF, $SEND_RAW) Sleep(3000) ControlSend($hCmd, "", "", "exit" & @CR) EndIf ;$hCmd NOT "0"... I don't really know if this is the best way to open the console and send commands into it.  I'm also not sure about how to best catch any errors that may occur...likely this needs to be accomplished with the STDOUTREAD command however I've not had experience using it before and therefore would appreciate some advice that anybody may offer. 
      Basically I'm seeking guidance on how to best automate the opening of the console, sending lines of commands to be executed, and handling any potential errors in the execution of those commands...I thank you in advance.  Regards.
    • By pctechtv
      I use a program called Screenpresso. It can run a command that captures the screen from certain coordinates. I would like to be able to capture the mouse coordinates and then fill them in my command. The normal command looks like this.
      screenpresso.exe -captureregion "D:\Test\test2.jpg" 0;0;1280;720 It is at 0;0 where I would like to insert the mouse coordinates. Can someone show me how to do this with AutoIt Thanks
    • By jacobestepp
      I am Very new to Autoit and I'm trying to figure out how to input text in an administrator Level Command prompt on windows 10. this is what I currently have
      Send ("#r") WinWaitActive("Run") Send("runas /user:Administrator cmd") Send("{Enter}") WinWait("C:\WINDOWS\system32\runas.exe") ControlClick("", "", "[CLASS:ConsoleWindowClass]") Send("test-Password") Send("{Enter}") The issue I am having is I can not send the "test-password" to the command prompt.  I cried adding the ControlClick command to place the cursor in he CMD box, but its still not working. What am I doing wrong?
    • By Jibberish
      Hi all,
      I need to read a log file into an array, but the log file is encoded as $FO_UTF16_BE_NOBOM (2048) = Use Unicode UTF16 Big Endian (without BOM) per FileGetEncoding (it returns 2048).
      I have searched how to convert these log files to UTF-8 and finally found a Powershell command. Since then I have been racking my brain trying to get the function to work. The command itself works from a Powerscript prompt:
      C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content C:\Logs\Myplayer_10-10-17-02-31.log | Set-Content -Encoding utf8 C:\Logs\Myplayer1.log This is my sandbox;
      #include <array.au3> #include <File.au3> Local $aArrayLogFile Local $sLogDir = "C:\Logs\" Local $sLogFile = "Myplayer_10-10-17-02-31.log" Local $sConvertedLog = "ConvertedLog.log" Local $sLogDirFile = $sLogDir&$sLogFile RunWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) _FileReadToArray($sLogDirFile, $aArrayLogFile) _ArrayDisplay($aArrayLogFile) Also tried
      RunWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) and
      ShellExecuteWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"," -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) Tried without -Command and a bunch of other parameters that were sprinkled throughout the internet from people trying to get this to work.
      Thanks
      Jibs
×
×
  • Create New...