realonameo Posted September 30, 2023 Posted September 30, 2023 Hi! First of all, I would like to thank you for reading my post. This will open Notepad and VLC: Quote #include <MsgBoxConstants.au3> Local $VLC = "V:\Software\VLC\VLCPortable.exe" $Notepad = $CmdLine[1] If $CmdLine[1] = "notepad" Then Run($Notepad & ".exe", "", @SW_SHOWMINIMIZED) Run($VLC, "", @SW_SHOWMAXIMIZED) EndIf MsgBox($MB_SYSTEMMODAL, "", "Script has command-line arguments.") But, this will open Notepad only, not open VLC: Quote #include <MsgBoxConstants.au3> Local $VLC = @WorkingDir & "\VLC\VLCPortable.exe " $Notepad = $CmdLine[1] If $CmdLine[1] = "notepad" Then Run($Notepad & ".exe", "", @SW_SHOWMINIMIZED) Run($VLC, "", @SW_SHOWMAXIMIZED) EndIf MsgBox($MB_SYSTEMMODAL, "", "Script has command-line arguments.") May I know why @WorkingDir not worked?
Solution Andreik Posted September 30, 2023 Solution Posted September 30, 2023 Probably because when you run notepad, system directory will be set as working directory and VLCPortable.exe it's certainly not in this location.
ioa747 Posted September 30, 2023 Posted September 30, 2023 (edited) placing this line ConsoleWrite("$VLC=" & $VLC & @CRLF) Run($VLC, "", @SW_SHOWMAXIMIZED) Maybe it will solve your question example #include <MsgBoxConstants.au3> Local $Notepad = $CmdLine[1] If $CmdLine[1] = "notepad" Then Run($Notepad & ".exe", "", @SW_SHOWMINIMIZED) ;~ Run($VLC, "", @SW_SHOWMAXIMIZED) Local $VLC = @WorkingDir & "\VLC\VLCPortable.exe" ConsoleWrite("$VLC=" & $VLC & @CRLF) $VLC = @ScriptDir & "\VLC\VLCPortable.exe" ConsoleWrite("$VLC=" & $VLC & @CRLF) ConsoleWrite("shortName: " & '"' & FileGetShortName($VLC) & '"' & @CRLF) ConsoleWrite("LongName: " & '"' & $VLC & '"' & @CRLF) Run('"' & $VLC & '"', "", @SW_SHOWMAXIMIZED) EndIf MsgBox($MB_SYSTEMMODAL, "", "Script has " & $CmdLine[0] - 1 & " command-line arguments.") Edited September 30, 2023 by ioa747 Edit I know that I know nothing
realonameo Posted September 30, 2023 Author Posted September 30, 2023 41 minutes ago, Andreik said: Probably because when you run notepad, system directory will be set as working directory and VLCPortable.exe it's certainly not in this location. @Andreik Thank you for the hint! I just change @WorkingDir to @ScriptDir. My problem solved. But, based on your explanation, when I try delete this line: Run($Notepad & ".exe", "", @SW_SHOWMINIMIZED) @WorkingDir still not work. VLC still not open.
realonameo Posted September 30, 2023 Author Posted September 30, 2023 51 minutes ago, ioa747 said: placing this line ConsoleWrite("$VLC=" & $VLC & @CRLF) Run($VLC, "", @SW_SHOWMAXIMIZED) Maybe it will solve your question example #include <MsgBoxConstants.au3> Local $Notepad = $CmdLine[1] If $CmdLine[1] = "notepad" Then Run($Notepad & ".exe", "", @SW_SHOWMINIMIZED) ;~ Run($VLC, "", @SW_SHOWMAXIMIZED) Local $VLC = @WorkingDir & "\VLC\VLCPortable.exe" ConsoleWrite("$VLC=" & $VLC & @CRLF) $VLC = @ScriptDir & "\VLC\VLCPortable.exe" ConsoleWrite("$VLC=" & $VLC & @CRLF) ConsoleWrite("shortName: " & '"' & FileGetShortName($VLC) & '"' & @CRLF) ConsoleWrite("LongName: " & '"' & $VLC & '"' & @CRLF) Run('"' & $VLC & '"', "", @SW_SHOWMAXIMIZED) EndIf MsgBox($MB_SYSTEMMODAL, "", "Script has " & $CmdLine[0] - 1 & " command-line arguments.") @ioa747 I have run your example code. It show this: $VLC=V:\Software\VLC\VLCPortable.exe $VLC=V:\Software\VLC\VLCPortable.exe shortName: "V:\Software\VLC\VLCPortable.exe" LongName: "V:\Software\VLC\VLCPortable.exe" However, my problem solved by change @WorkingDir to @ScriptDir. Thank you!
Andreik Posted September 30, 2023 Posted September 30, 2023 6 hours ago, realonameo said: But, based on your explanation, when I try delete this line: Run($Notepad & ".exe", "", @SW_SHOWMINIMIZED) @WorkingDir still not work. VLC still not open. Using your example that doesn't work, please show us what is printed in the console when you run this code: #include <MsgBoxConstants.au3> Local $VLC = @WorkingDir & "\VLC\VLCPortable.exe " $Notepad = $CmdLine[1] If $CmdLine[1] = "notepad" Then ConsoleWrite(@WorkingDir & @CRLF) Run($Notepad & ".exe", "", @SW_SHOWMINIMIZED) ConsoleWrite($VLC & @CRLF) Run($VLC, "", @SW_SHOWMAXIMIZED) EndIf MsgBox($MB_SYSTEMMODAL, "", "Script has command-line arguments.")
realonameo Posted October 2, 2023 Author Posted October 2, 2023 >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "V:\Soft Ware\Soft Ware\Test.au3" /UserParams notepad +>15:56:55 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0) Keyboard:00000409 OS:WIN_10/2009 CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\FAZ-FX505D\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\FAZ-FX505D\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.16.0) from:C:\Program Files (x86)\AutoIt3 input:V:\Soft Ware\Soft Ware\Test.au3 +>15:56:56 AU3Check ended.rc:0 >Running:(3.3.16.0):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "V:\Soft Ware\Soft Ware\Test.au3" notepad +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. V:\Soft Ware\Soft Ware V:\Soft Ware\Soft Ware\VLC\VLCPortable.exe +>15:56:58 AutoIt3.exe ended.rc:0 +>15:56:58 AutoIt3Wrapper Finished. >Exit code: 0 Time: 3.116 Sorry. I do not know how. There is no problem using @WorkingDir today, it works, it will open notepad and VLC. I have build the code and run through Windows Command Prompt and it works, it will open notepad and VLC. I do not know why VLC cannot be open on last Saturday, even when I use ioa747 example code it shows WorkingDir is same result as ScriptDir. Thank you for your time, @Andreik.
Andreik Posted October 2, 2023 Posted October 2, 2023 Anyway, it's safer to use @ScriptDir or some path that it's unlikely to change under some circumstances.
realonameo Posted October 2, 2023 Author Posted October 2, 2023 On 9/30/2023 at 9:29 PM, Andreik said: Probably because when you run notepad, system directory will be set as working directory and VLCPortable.exe it's certainly not in this location. Thank you for the information provided. Based on your reply above, I will only use @ScriptDir from now on and will always check file path by using ConsoleWrite first.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now