making a batchfile in autoit

3

i checked my file with

MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & $sFileRead)

so i know i created the file successfully

but when i want to change it to .bat by moving it into a junk .bat file (other people probably have a better way of doing it) i get an error.

$CMD = "move "$sFilePath" " & $jointpath & @CRLF
RunWait(@ComSpec & " /c " & $CMD)

i get

error: syntax error

here is the whole function:

Func makeJointBat()
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)
    FileWrite($sFilePath, "you don't need to know what i wrote there")
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
    Local $sFileRead = FileRead($hFileOpen)
    FileClose($hFileOpen)
    $CMD = "move "$sFilePath" " & $jointpath & @CRLF
    RunWait(@ComSpec & " /c " & $CMD)
EndFunc   ;==>makeJointBat

burih yidah leib

Posted 2020-01-06T08:31:08.873

Reputation: 67

Try removing that & @CRLF at the end of the $CMD = ... command. – LPChip – 2020-01-06T09:03:56.283

Answers

3

The problem might be that you seem to be opening the file two times: Once when creating it, then again when reading it.

However, you are only closing it once.

Adding a FileClose between the FileWrite and the FileOpen might help with the problem.

harrymc

Posted 2020-01-06T08:31:08.873

Reputation: 306 093