Jump to content

Cmd window of batch file not opening at all


Recommended Posts

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

image.png.1e8e56256cad908026a475c9ea507f7f.png

Is there something that is being done wrong? (Yes I have installed the file)

image.png.843a2452f74a76edd35cae76c0588d87.png

 

Link to comment
Share on other sites

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 by TheXman
Link to comment
Share on other sites

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 by Musashi

Musashi-C64.png

"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

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 by Musashi

Musashi-C64.png

"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

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.

Link to comment
Share on other sites

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 ?

Musashi-C64.png

"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

@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.

Musashi-C64.png

"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

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 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

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.

 

Musashi-C64.png

"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

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 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

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!

Link to comment
Share on other sites

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 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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...