Jump to content

Running Batch File "Run" Problem


Recommended Posts

             Run("C:\S3_GUI\ncat\Home.bat")  ; This works as expected but flashes up unwanted command prompt
             Run(@ComSpec & " /c " & "C:\S3_GUI\ncat\Home.bat", "", @SW_HIDE) ; this doesn't work even with HIDE removed

echo off
Rem Check head is @ HOME..
echo !HH | ncat 192.168.1.6 80 > homerep

(ncat is 'safe' version of Windows banned netcat)

The most powerful number in the Universe.  Zero.

Link to comment
Share on other sites

  • Developers
6 hours ago, fopetesl said:

Run(@ComSpec & " /c " & "C:\S3_GUI\ncat\Home.bat", "", @SW_HIDE) ; this doesn't work even with HIDE removed

What happens when you change the /c to a /k so the cmd windows stays open and you have the opportunity to read any generated responses?

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

Link to comment
Share on other sites

With or without @SW_HIDE makes no difference.

If I run the bat file from command line it works and produces the response file homerep.

Either Run command doesn't produce homerep.

Command window flashes up for a very brief period if @SW_HIDE isn't used.

The most powerful number in the Universe.  Zero.

Link to comment
Share on other sites

  • Developers

So what does happen when you do the /k option?

Run(@ComSpec & " /k C:\S3_GUI\ncat\Home.bat")

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

Link to comment
Share on other sites

13 hours ago, Jos said:

So what does happen when you do the /k option?

Run(@ComSpec & " /k C:\S3_GUI\ncat\Home.bat")

Jos

You may have revealed the cause, Jos.

Cmd.exe is running in system32, not the directory where the ncat.exe and .bat files reside.

How to make cmd.exe work in my directory?

 

CmdError.jpg

Edited by fopetesl
Wrong initial conclusion

The most powerful number in the Universe.  Zero.

Link to comment
Share on other sites

  • Developers

Just set the proper workdir ( current directory for the process) to the directory containing the ncat.exe or add the directory to the PATH.

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

Link to comment
Share on other sites

5 minutes ago, Jos said:

Just set the proper workdir ( current directory for the process) to the directory containing the ncat.exe or add the directory to the PATH.

Jos

I used FileChangeDir() which works but untidy :(

I'll use the PATH when it gets onto the final machine.

The most powerful number in the Universe.  Zero.

Link to comment
Share on other sites

3 hours ago, fopetesl said:

I used FileChangeDir() which works but untidy :(

Or you could do as Jos said, and use the WorkingDir parameter of the Run command and see if that works.

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