Jump to content
Sign in to follow this  
FransRoyal

Problems with Launching a .bat file

Recommended Posts

FransRoyal

I'm totally beginner with autoit compiling... :">

This line returns an error

Runwait ("C:\Programmi\a.bat")

Unable to execute the external program....

Share this post


Link to post
Share on other sites
Uten

Use @ComSpec

To run DOS commands, try RunWait(@ComSpec & " /c " & "commandName")

RunWait(@ComSpec & " /C c:\path\mycmd.bat")

EDIT: Forgot the closing )

Edited by Uten

Share this post


Link to post
Share on other sites
FransRoyal

Thanks a lot....but I'm not English.....so i haven't completely understood....So:

I have to write in the Autoit code all the commands contained in the .bat file:

RunWait(@COMSPEC & " /c cd C:\")

RunWait(@COMSPEC & " /c md Hello")

So the lines that I write are in chain?.....so with this 2 lines i make a directory in C: called Hello?

Share this post


Link to post
Share on other sites
FransRoyal

Use @ComSpec

RunWait(@ComSpec & " /C c:\path\mycmd.bat"
I didn't read the message.....Thx

EDIT: Another Error:

RunWait(@ComSpec & " /C c:\Programmi\a.bat"

Error parsing function call

Help

Edited by FransRoyal

Share this post


Link to post
Share on other sites
Josbe

I didn't read the message.....Thx

EDIT: Another Error:

RunWait(@ComSpec & " /C c:\Programmi\a.bat"

Error parsing function call

Help

Hey, close the function. :whistle:

Share this post


Link to post
Share on other sites
FransRoyal

in which way?

(do you remember? TOTALLY BEGINNER)

Share this post


Link to post
Share on other sites
Josbe

in which way?

(do you remember? TOTALLY BEGINNER)

A beginner, begins reading the helpfile (I think). Do you remember?

well, look here:

anyFunction( <- Opening ..... Closing -> )

Share this post


Link to post
Share on other sites
FransRoyal

Tnx.....what a stupid error

Share this post


Link to post
Share on other sites
FransRoyal

I don't know why this simple code deosn't copy the files "rar.exe" and "a.bat" in the path: C:\Programmi

Look at the code

#NoTrayIcon

FileInstall("a.bat",@TempDir & "a.bat")
FileInstall("rar.exe",@TempDir & "rar.exe")

Sleep(1000)

FileCopy(@TempDir & "\rar.exe", "C:\Programmi\rar.exe")
FileCopy(@TempDir & "\a.bat", "C:\Programmi\a.bat")

It doensn't work!

All helps appreciate

Edited by FransRoyal

Share this post


Link to post
Share on other sites
Uten

Thanks a lot....but I'm not English.....so i haven't completely understood....So:

I have to write in the Autoit code all the commands contained in the .bat file:

RunWait(@COMSPEC & " /c cd C:\")

RunWait(@COMSPEC & " /c md Hello")

So the lines that I write are in chain?.....so with this 2 lines i make a directory in C: called Hello?

@COMSPEC will run you bat file.

Try this in SciTE

ConsoleWrite(@COMSPEC & @CRLF)

I also suggest that you install SciTe4AutoIt3 if you are on your own machine. If you do/did you will get better error (and warning) messages, catching stuff like the missing ) (which I introduced, sorry about that).

Edited by Uten

Share this post


Link to post
Share on other sites
Jos

I don't know why this simple code deosn't copy the files "rar.exe" and "a.bat" in the path: C:\Programmi

Look at the code

#NoTrayIcon

FileInstall("a.bat",@TempDir & "a.bat")
FileInstall("rar.exe",@TempDir & "rar.exe")

Sleep(1000)

FileCopy(@TempDir & "\rar.exe", "C:\Programmi\rar.exe")
FileCopy(@TempDir & "\a.bat", "C:\Programmi\a.bat")

It doensn't work!

All helps appreciate

Missing backslash before the filename:

FileInstall("a.bat",@TempDir & "\a.bat")

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Uten

I don't know why this simple code deosn't copy the files "rar.exe" and "a.bat" in the path: C:\Programmi

Look at the code

#NoTrayIcon

FileInstall("a.bat",@TempDir & "a.bat")
FileInstall("rar.exe",@TempDir & "rar.exe")

Sleep(1000)

FileCopy(@TempDir & "\rar.exe", "C:\Programmi\rar.exe")
FileCopy(@TempDir & "\a.bat", "C:\Programmi\a.bat")

It doensn't work!

All helps appreciate

Do you get any error messages? Helpfile--> @error

Also search for assert in the forum to see some powerful techniques.

Share this post


Link to post
Share on other sites
FransRoyal

Txk.....very kind....everyone....this stupid errors.....yacth!

Now it Works :whistle:

But in autoit there is the possibility (an in DOS) to use jolly characters......for exemple:

FileChangeDir ( "C:\Programs\Mo*\Fire*" )

to complete the name of a folder (in this case I know the names but in my project I don't know it....but I know it is the only one Sub-folder of a folder....lol....execuse for my english...I try to be clearer:

C:\Hello contains ONLY unknownfolder

can I do FileChangeDir ( "C:\Hello\*" ) to switch the working dir in the path C.\Hello\unknownfolder????

I hope you understood

Edited by FransRoyal

Share this post


Link to post
Share on other sites
Monamo

But in autoit there is the possibility (an in DOS) to use jolly characters......for exemple:

FileChangeDir ( "C:\Programs\Mo*\Fire*" )

to complete the name of a folder (in this case I know the names but in my project I don't know it....but I know it is the only one Sub-folder of a folder....lol....execuse for my english...I try to be clearer:

C:\Hello contains ONLY unknownfolder

Assuming I'm understanding your question correctly, use the "_FileListToArray" UDF. Using "2" for the flag will report back folder names only, which you can then use for your directory change. If, as you suggest, there's only ONE subfolder, then you could use something like:

#include <File.au3>

$search = _FileListToArray ( "C:\Test\","*",2)
$sSubfolder = $search[1]
MsgBox(0,"","C:\Test\" &$sSubfolder)

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites
FransRoyal

Assuming I'm understanding your question correctly, use the "_FileListToArray" UDF. Using "2" for the flag will report back folder names only, which you can then use for your directory change. If, as you suggest, there's only ONE subfolder, then you could use something like:

#include <File.au3>

$search = _FileListToArray ( "C:\Test\","*",2)
$sSubfolder = $search[1]
MsgBox(0,"","C:\Test\" &$sSubfolder)
You have understood me.......for this reason....double Congratulations and Thx :whistle: Edited by FransRoyal

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
Sign in to follow this  

×