IcyCascades Posted January 14, 2020 Share Posted January 14, 2020 Posted a separate problem earlier but now I'm having another. One of the main purposes of the script I'm trying to create is to run a master batch file with a menu that will do various things. I have this code in place, but it does not appear to be running the batch file or even opening a cmd window Is there something that is being done wrong? (Yes I have installed the file) Link to comment Share on other sites More sharing options...
ModemJunki Posted January 14, 2020 Share Posted January 14, 2020 Is the batch file in a folder, or in the root of a drive? The help for @ScriptDir says "Directory containing the running script. Only includes a trailing backslash when the script is located in the root of a drive." Always carry a towel. Link to comment Share on other sites More sharing options...
IcyCascades Posted January 14, 2020 Author Share Posted January 14, 2020 It's in the root of a drive Link to comment Share on other sites More sharing options...
TheXman Posted January 14, 2020 Share Posted January 14, 2020 (edited) First, please stop posting images of your code. Post actual code snippets using the code tags "<>" in the editor's ribbon. Using images makes it impossible to cut & paste text. The destination of your FileInstall is : @ScriptDir & "\" & $sFolder & "\Main.bat" But you are trying to execute: @ScriptDir & "\Main.bat" Edited January 14, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Musashi Posted January 14, 2020 Share Posted January 14, 2020 (edited) 1 hour ago, IcyCascades said: I'm trying to create is to run a master batch file with a menu that will do various things. In addition to the errors described above. Here is an example with a .cmd file (TestBatch.cmd) that contains a menu. #include <File.au3> Global $sFileTargetPath, $iFileInstall $sFileTargetPath = @ScriptDir & "\TestBatch.cmd" $iFileInstall = FileInstall ("TestBatch.cmd", $sFileTargetPath, $FC_OVERWRITE) If $iFileInstall Then ConsoleWrite("+ @@DEBUG : FileInstall OK" & @CRLF) ; *** just for display Run(@ComSpec & ' /c "' & $sFileTargetPath & '"', "", @SW_SHOWMAXIMIZED) Else ConsoleWrite("! @@DEBUG : FileInstall ERROR" & @CRLF) ; *** just for display Exit EndIf Keep in mind : "The source file must be specified using a string literal and can not be a variable, a macro, a calculation nor function call." TestBatch.cmd Edited January 14, 2020 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
ModemJunki Posted January 15, 2020 Share Posted January 15, 2020 I forgot to post example of workaround for the @ScriptDir having backslash if root of drive. I use this: Global $s_LocDir = @ScriptDir If StringRight($s_LocDir, 1) = "\" Then $s_LocDir = StringTrimRight($s_LocDir, 1) ; to assure the string never has "\" at the end Always carry a towel. Link to comment Share on other sites More sharing options...
Musashi Posted January 15, 2020 Share Posted January 15, 2020 (edited) 15 minutes ago, ModemJunki said: I use this: To assure that there is no trailing backslash, better use _WinAPI_PathRemoveBackslash : #include <WinAPIShPath.au3> Global $g_sDir = 'C:\Temp\' ConsoleWrite('$g_sDir 1. = ' & $g_sDir & @CRLF) ConsoleWrite('$g_sDir 2. = ' & _WinAPI_PathRemoveBackslash($g_sDir) & @CRLF) Edited January 15, 2020 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
TheXman Posted January 15, 2020 Share Posted January 15, 2020 4 minutes ago, Musashi said: To assure that there is no trailing backslash, better use _WinAPI_PathRemoveBackslash For the record the API used in _WINAPI_PathRemoveBackslash, PathRemoveBackslashW, has been deprecated. PathCchRemoveBackslash or PathCchRemoveBackslashEx, should be used in place of PathRemoveBackslashW to prevent the possibility of a buffer overrun. Musashi 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Musashi Posted January 15, 2020 Share Posted January 15, 2020 23 minutes ago, TheXman said: For the record : the API used in _WINAPI_PathRemoveBackslash, PathRemoveBackslashW, has been deprecated. Thanks for the info. The following can be found (as you have already written) in the Microsoft-Docs : "Note This function is deprecated. We recommend the use of the PathCchRemoveBackslash or PathCchRemoveBackslashEx function in its place. " The recent AutoIt Help, the History and the AutoIt Changelog do not mention it. Has this already been considered in the Beta ? "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Musashi Posted January 15, 2020 Share Posted January 15, 2020 @ModemJunki Just to avoid confusion - there is nothing wrong with your code snippet . As an alternative to _WinAPI_PathRemoveBackslash you could also use e.g. the following : Global $g_sDir = "c:\Temp\SubDir\" ConsoleWrite('Before = ' & $g_sDir & @CRLF) ConsoleWrite('After = ' & StringRegExpReplace($g_sDir, "\\$", "") & @CRLF) Finally, however, these are only different solutions for the same thing. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
BrewManNH Posted January 16, 2020 Share Posted January 16, 2020 17 hours ago, Musashi said: Just to avoid confusion Having the doubled backslash in the path won't affect anything in Windows, as far as Windows is concerned C:\Temp and C:\\Temp are equivalent. 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 GudeHow 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 More sharing options...
Musashi Posted January 16, 2020 Share Posted January 16, 2020 17 minutes ago, BrewManNH said: Having the doubled backslash in the path won't affect anything in Windows The only point was to remove a backslash that might be present at the end of the path. For this purpose various (not all) options were offered in the contributions above. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
BrewManNH Posted January 16, 2020 Share Posted January 16, 2020 20 hours ago, TheXman said: For the record the API used in _WINAPI_PathRemoveBackslash, PathRemoveBackslashW, has been deprecated. Following the links you provided shows that the 2 substitute functions won't remove the trailing backslash if the path is the root of the directory. Quote This function will not remove the backslash from a root path string, such as "C:". 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 GudeHow 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 More sharing options...
TheXman Posted January 16, 2020 Share Posted January 16, 2020 1 minute ago, BrewManNH said: Following the links you provided shows that the 2 substitute functions won't remove the trailing backslash if the path is the root of the directory. Then take your complaint to Microsoft! CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
BrewManNH Posted January 16, 2020 Share Posted January 16, 2020 1 minute ago, TheXman said: Then take your complaint to Microsoft! Where in that post did you manage to find a complaint? It was an expansion of the thread and a warning to not rely on it if the path is at the root. 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 GudeHow 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 More sharing options...
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