Jump to content

Problems with Launching a .bat file


Recommended Posts

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

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?

Link to comment
Share on other sites

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

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

  • Developers

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 etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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]

Link to comment
Share on other sites

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