Jump to content

run notepad++ and receive parameter from command line

Recommended Posts


I can run this and notepad++ opens the file Run("C:\Program Files (x86)\Notepad++\notepad++.exe E:\icare\icare\NI-WI-NBSE-ERR.xml")

But what I want is to run the .au3 or exe from command line and send it the file as parameter -am I being to simplistic in hoping its this easy?

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>
;Run("C:\Program Files (x86)\Notepad++\notepad++.exe E:\icare\icare\NI-WI-NBSE-ERR.xml")

Run("C:\Program Files (x86)\Notepad++\notepad++.exe " & $CmdLine[0] )
sleep (200)
sleep (500)
sleep (500)
sleep (500)
sleep (500)


Share this post

Link to post
Share on other sites

CmdLine[0] is the count, you need to use CmdLine[1]

Also you can use ^ in place of Control + in place of Shift so something like this:

If $CmdLine[0] > 0 Then
    If FileExists($CmdLine[1]) Then
        Run(@ProgramFilesDir & '\Notepad++\notepad++.exe "' & $CmdLine[1] & '"')
        sleep (500)
        sleep (500)
        sleep (500)


Edited by Subz

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

  • Similar Content

    • jacobestepp
      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?
    • Phil Viton
      By Phil Viton
      autoit3 under Win7 (x64)
      Here's a very simple script that reports the number
      of parameters it's called with:
      $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)
    • Jibberish
      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.
    • Tigerweld
      By Tigerweld
      How do I make this variable work?
      $MY_SESSION_ID = for /f "tokens=3-4" %%a in ('query session %username%') do @if "%%b"=="Active" set MY_SESSION_ID=%%a MsgBox(1, "My Session ID", "Session ID is: " & $MY_SESSION_ID)  
    • theak
      By theak
      ShellExecute("\\servername\cofs\Organization\ITS\_Software & Hardware\AS400\DVD\Windows\cwblaunch.exe", '"/v/qn ADDLOCAL=ALL"')  I had to dig to find the right setup.exe according to the documentation but I got it to run. However, it pops up with this dialog box (attached) showing me the command line parameters, as if I'm incorrect.
      It continues to run the install however, but seemingly without any of the command line parameters.
      Here's the command I entered into the CMD prompt exactly:
      "\\servername\cofs\Organization\ITS\_Software & Hardware\AS400\DVD\Windows\image64a\setup.exe",'"/v/qn ADDLOCAL=ALL"'