Jump to content

Help needed


Skitty
 Share

Recommended Posts

Directly from the help file:

$file = FileOpen("test.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, "Line1")
FileWrite($file, "Still Line1" & @CRLF)
FileWrite($file, "Line2")

FileClose($file)

That's how to open a file. And write to it. And save it. All in one example from the HELP FILE.

[center][/center]

Link to comment
Share on other sites

FileOpen ( "filename" [, mode ] )

Can be a combination of the following:

0 = Read mode (default)

1 = Write mode (append to end of file)

2 = Write mode (erase previous contents)

8 = Create directory structure if it doesn't exist (See Remarks).

16 = Force binary mode (See Remarks).

32 = Use Unicode UTF16 Little Endian reading and writing mode. Reading does not override existing BOM.

64 = Use Unicode UTF16 Big Endian reading and writing mode. Reading does not override existing BOM.

128 = Use Unicode UTF8 (with BOM) reading and writing mode. Reading does not override existing BOM.

256 = Use Unicode UTF8 (without BOM) reading and writing mode.

16384 = When opening for reading and no BOM is present, use full file UTF8 detection. If this is not used then only the initial part of the file is checked for UTF8.

The folder path must already exist (except using mode '8' - See Remarks).

The ,2) you see in the FileOpen will create the file, or erase it's contents and recreate it. If you do 10 it'll even create your temp directory if it does not exist.

You may think these guys are busting your chops but everything i've learned in AutoIt I owe to the help file. The more you use AutoIt and read the help file/examples the better you'll get. You seriously sound like you're over thinking the whole process.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         ZacUSNYR

 Script Function:
    Create a Batch file in temp dir and run it.

#ce ----------------------------------------------------------------------------

Global $tempdir = "C:\TEMP2"
Global $batchfile = "runme.bat"

$createbatch = FileOpen($tempdir & Chr(92) & $batchfile, 10)

If $createbatch = -1 Then
    MsgBox(0, "Error", "Unable to create batch file.")
Else

FileWrite($createbatch, "@ECHO OFF" & @LF)
FileWrite($createbatch, "ECHO Welcome to my Created Batch File" & @LF)
FileWrite($createbatch, "net use" & @LF)
FileWrite($createbatch, "pause" & @LF)
FileClose($createbatch)

RunWait(@ComSpec & " /c " & $tempdir & Chr(92) & $batchfile)
EndIf

That does exactly what you're looking for. Checks if dir is there, if not, creates it. If file is there it erases it and puts in what you have. If file is not there it creates it. If permissions are an issue expect to see a popup for the error.

This is exactly what does not help you. Someone writing it for you.

Link to comment
Share on other sites

sigh, have you even seriously looked at the posted example by ZacUSNYR?

Have you even tried to understand it?

now... go away and do not come back till you have read it and do the researched and testing!

Bad problem...

$file = FileOpen ("c:\temp\a.bat" , 2)
FileWrite($file, "if EXIST "Control Panel.{21eC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK" & @CRLF)
FileClose($file)

How do I prevent "21e" "3" "1069" etc from being passed out as commands? and instread, just get typed into the .bat file.

Link to comment
Share on other sites

  • Developers

Bad problem...

$file = FileOpen ("c:\temp\a.bat" , 2)
FileWrite($file, "if EXIST "Control Panel.{21eC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK" & @CRLF)
FileClose($file)

How do I prevent "21e" "3" "1069" etc from being passed out as commands? and instread, just get typed into the .bat file.

use single quotes around your literal string when the actual string contains double quotes.

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

FileOpen ( "filename" [, mode ] )

Can be a combination of the following:

0 = Read mode (default)

1 = Write mode (append to end of file)

2 = Write mode (erase previous contents)

8 = Create directory structure if it doesn't exist (See Remarks).

16 = Force binary mode (See Remarks).

32 = Use Unicode UTF16 Little Endian reading and writing mode. Reading does not override existing BOM.

64 = Use Unicode UTF16 Big Endian reading and writing mode. Reading does not override existing BOM.

128 = Use Unicode UTF8 (with BOM) reading and writing mode. Reading does not override existing BOM.

256 = Use Unicode UTF8 (without BOM) reading and writing mode.

16384 = When opening for reading and no BOM is present, use full file UTF8 detection. If this is not used then only the initial part of the file is checked for UTF8.

The folder path must already exist (except using mode '8' - See Remarks).

The ,2) you see in the FileOpen will create the file, or erase it's contents and recreate it. If you do 10 it'll even create your temp directory if it does not exist.

You may think these guys are busting your chops but everything i've learned in AutoIt I owe to the help file. The more you use AutoIt and read the help file/examples the better you'll get. You seriously sound like you're over thinking the whole process.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         ZacUSNYR

 Script Function:
    Create a Batch file in temp dir and run it.

#ce ----------------------------------------------------------------------------

Global $tempdir = "C:\TEMP2"
Global $batchfile = "runme.bat"

$createbatch = FileOpen($tempdir & Chr(92) & $batchfile, 10)

If $createbatch = -1 Then
    MsgBox(0, "Error", "Unable to create batch file.")
Else

FileWrite($createbatch, "@ECHO OFF" & @LF)
FileWrite($createbatch, "ECHO Welcome to my Created Batch File" & @LF)
FileWrite($createbatch, "net use" & @LF)
FileWrite($createbatch, "pause" & @LF)
FileClose($createbatch)

RunWait(@ComSpec & " /c " & $tempdir & Chr(92) & $batchfile)
EndIf

That does exactly what you're looking for. Checks if dir is there, if not, creates it. If file is there it erases it and puts in what you have. If file is not there it creates it. If permissions are an issue expect to see a popup for the error.

This is exactly what does not help you. Someone writing it for you.

I've been awake since last night trying to finish this huge script, thanks for the help btw.

Link to comment
Share on other sites

Now the question I have for you, why bother creating a batch file? What is it you're trying to do with the batch file creation/execution that cannot be done in AutoIt?

Its just supposed to be a fun little program. I'll post it all once i'm done.

You've probably seen something similar.

Link to comment
Share on other sites

OK!!! SO HERE I PRESENT THE FINAL PRODUCT!!!! this would have never been possible (for me) If it weren't for all of you helpful people!! THANK YOU :)

#include <Inet.au3>

#Include <File.au3>

#include <String.au3>

Global Const $BS_ICON = 0x0040

Global Const $BS_PUSHLIKE = 0x1000

Global Const $ES_READONLY = 2048

Global Const $GUI_FOCUS = 256

Global Const $CBS_DROPDOWNLIST = 0x0003

Global Const $GUI_ENABLE = 64

Global Const $GUI_DISABLE = 128

Global Const $ES_PASSWORD = 32

Global $aHButtons[10], $IniRead[10]

Global $WindowList, $Password, $PixelColor, $xPos, $yPos

If Not FileExists("C:\WINDOWS\Web\Wallpaper") Then DirCreate("C:\WINDOWS\Web\Wallpaper")

If Not FileExists("C:\WINDOWS\Web\Wallpaper\a.bat") Then _FileCreate("C:\WINDOWS\Web\Wallpaper\a.bat")

_Check()

_Menu()

Func _Menu()

$MainGUI = GUICreate("Menu~", 170, 165, -1, -1)

$ApplicationLauncher = GUICtrlCreateButton("Application Launcher", 10, 10, 150)

$WindowManager = GUICtrlCreateButton("Window Manager", 10, 40, 150)

$SetPassword = GUICtrlCreateButton("* Set Password *", 10, 70, 150)

$Homepage = GUICtrlCreateButton("AutoIT", 10, 100, 150)

$Launcher = GUICtrlCreateButton("Launch", 10, 130, 150)

GUISetState()

While 1

$nMsg = GUIGetMsg()

Select

Case $nMsg = -3

Exit

Case $nMsg = $ApplicationLauncher

GUIDelete($MainGUI)

_AppLauncher()

Case $nMsg = $WindowManager

GUIDelete($MainGUI)

_WinManager()

Case $nMsg = $SetPassword

GUIDelete($MainGUI)

_Password()

Case $nMsg = $Homepage

_Homepage()

Case $nMsg = $Launcher

_Launcher()

EndSelect

WEnd

EndFunc

Func _AppLauncher()

$GUI = GUICreate("Application Launcher~", 130, 355, -1, -1)

GUICtrlCreateGroup("Applications", 10, 10, 110, 270)

$ClearData = GUICtrlCreateButton("Clear all Data", 10, 290, 110)

$ReturnMenu = GUICtrlCreateButton("Return to Menu", 10, 320, 110)

Local $left = 20, $top = 30

For $i = 0 To UBound($aHButtons) - 1

$aHButtons[$i] = GUICtrlCreateButton("", $left, $top, 40, 40, $BS_ICON + $BS_PUSHLIKE)

$top += 50

If $i == 4 Then

$left = 70

$top = 30

EndIf

Next

If FileExists("C:\WINDOWS\Web\Wallpaper\$~settings.ini") Then

For $i = 0 To UBound($aHButtons) - 1

$IniRead[$i] = IniRead("C:\WINDOWS\Web\Wallpaper\$~settings.ini", "AppLauncher", "Button" & $i, "Not Found")

If $IniRead[$i] <> "Not Found" Then GUICtrlSetImage($aHButtons[$i], $IniRead[$i], 1)

Next

EndIf

GUISetState()

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case -3

Exit

Case $aHButtons[0] To $aHButtons[uBound($aHButtons) - 1]

For $i = 0 To UBound($aHButtons) - 1

If $aHButtons[$i] == $nMsg Then

$IniRead[$i] = IniRead(""C:\WINDOWS\Web\Wallpaper\$~settings.ini", "AppLauncher", "Button" & $i, "Not Found")

If FileExists(""C:\WINDOWS\Web\Wallpaper\$~settings.ini") And $IniRead[$i] <> "Not Found" Then

ShellExecute($IniRead[$i])

Else

$fod_Button = FileOpenDialog("Select a file", @DesktopDir, "Executeable's (*.exe)", 3, "", $GUI)

If Not @error Then

IniWrite(""C:\WINDOWS\Web\Wallpaper\$~settings.ini", "AppLauncher", "Button" & $i, $fod_Button)

GUICtrlSetImage($aHButtons[$i], $fod_Button, 1)

EndIf

EndIf

EndIf

Next

Case $ClearData

If FileExists(""C:\WINDOWS\Web\Wallpaper\$~settings.ini") Then

FileDelete(""C:\WINDOWS\Web\Wallpaper\$~settings.ini")

Else

MsgBox(16, "ERROR", "No data saved!")

EndIf

Case $ReturnMenu

GUIDelete($GUI)

_Menu()

EndSwitch

WEnd

EndFunc

Func _WinManager()

$GUI = GUICreate("Window Manager~", 290, 240, -1, -1)

GUICtrlCreateGroup("Window Manager", 10, 10, 270, 195)

GUICtrlCreateLabel("Windows", 20, 30)

$WindowList = GUICtrlCreateCombo("Select a Window", 20, 50, 250, 20, $CBS_DROPDOWNLIST)

$Activate = GUICtrlCreateButton("Activate Window", 20, 80, 120)

$Close = GUICtrlCreateButton("Close Window", 150, 80, 120)

$Flash = GUICtrlCreateButton("Flash Window", 20, 110, 150)

$HowManyInput = GUICtrlCreateInput(1, 180, 113, 40, 20)

$HowMany = GUICtrlCreateUpDown($HowManyInput)

GUICtrlSetLimit($HowMany, 99, 0)

GUICtrlCreateLabel("time(s)", 230, 116)

$GetProcess = GUICtrlCreateButton("Get Process", 20, 140, 120)

$GetText = GUICtrlCreateButton("Get Text", 150, 140, 120)

$KillWindow = GUICtrlCreateButton("Kill Window", 20, 170, 120)

$Refresh = GUICtrlCreateButton("Refresh", 150, 170, 120)

$ReturnMenu = GUICtrlCreateButton("Return to Menu", 70, 210, 150)

_Refresh()

GUISetState()

While 1

$nMsg = GUIGetMsg()

Select

Case $nMsg = -3

Exit

Case $nMsg = $Activate

WinActivate(GUICtrlRead($WindowList))

Case $nMsg = $Close

WinClose(GUICtrlRead($WindowList))

Case $nMsg = $Flash

WinFlash(GUICtrlRead($WindowList), "" , GUICtrlRead($HowManyInput))

Case $nMsg = $GetProcess

$Get = WinGetProcess(GUICtrlRead($WindowList))

MsgBox(0, Default, "Process ID: " & $Get)

Case $nMsg = $GetText

$Get = WinGetText(GUICtrlRead($WindowList))

MsgBox(0, Default, "Text found:" & @CRLF & $Get)

Case $nMsg = $KillWindow

WinKill(GUICtrlRead($WindowList))

Case $nMsg = $Refresh

_Refresh()

Case $nMsg = $ReturnMenu

GUIDelete($GUI)

_Menu()

EndSelect

WEnd

EndFunc

Func _Password()

$GUI = GUICreate("* Set Password *", 270, 110, -1, -1)

GUICtrlCreateLabel("Password", 10, 10)

GUICtrlCreateLabel("Encrypt Password", 10, 31)

GUICtrlCreateLabel("Encrypt Level", 10, 52)

$Password = GUICtrlCreateInput("", 110, 7, 150, 20, $ES_PASSWORD)

$EncryptPassword = GUICtrlCreateInput("", 110, 28, 150, 20, $ES_PASSWORD)

$EncryptLevel = GUICtrlCreateInput(1, 110, 49, 40, 20)

$UpDown = GUICtrlCreateUpDown($EncryptLevel)

GUICtrlSetLimit($UpDown, 10, 1)

$CreatePassword = GUICtrlCreateButton("Create Password", 60, 75, 150)

GUISetState()

While 1

$nMsg = GUIGetMsg()

Select

Case $nMsg = -3

GUIDelete($GUI)

_Menu()

Case $nMsg = $CreatePassword

$Read_Password = GUICtrlRead($Password)

$Read_EncryptPassword = GUICtrlRead($EncryptPassword)

$Read_Level = GUICtrlRead($EncryptLevel)

$Encrypted_Pass = _StringEncrypt(1, $Read_Password, $Read_EncryptPassword, $Read_Level)

IniWrite("C:\WINDOWS\Web\Wallpaper\$~settings.ini", "Password", "Pass", $Encrypted_Pass)

IniWrite("C:\WINDOWS\Web\Wallpaper\$~settings.ini", "Password", "EncPass", $Read_EncryptPassword)

IniWrite("C:\WINDOWS\Web\Wallpaper\$~settings.ini", "Password", "EncLevel", $Read_Level)

GUIDelete($GUI)

MsgBox(64, "* Password *", "Password succesfully set. Please restart the program.")

Exit

EndSelect

WEnd

EndFunc

Func _Homepage()

ShellExecute("http://www.Autoitscript.com")

EndFunc

Func _Refresh()

$List = WinList()

For $i = 1 To $List[0][0]

If $List[$i][0] <> "" And IsVisible($List[$i][1]) Then

GUICtrlSetData($WindowList, $List[$i][0])

EndIf

Next

EndFunc

Func IsVisible($Handle)

If BitAnd(WinGetState($Handle), 2) Then

Return 1

Else

Return 0

EndIf

EndFunc

; # START - FUNCTIONS #

Func _Check()

If FileExists("C:\WINDOWS\Web\Wallpaper\$~settings.ini") And IniRead("C:\WINDOWS\Web\Wallpaper\$~settings.ini", "Password", "Pass", "Not Found") <> "Not Found" Then

$GetPassword = InputBox("* Password *", "Please enter the password", "", "*", 200, 130)

$Read_Pass = IniRead("C:\WINDOWS\Web\Wallpaper\$~settings.ini", "Password", "Pass", "Not Found")

$Read_EncPass = IniRead("C:\WINDOWS\Web\Wallpaper\$~settings.ini", "Password", "EncPass", "Not Found")

$Read_EncLevel = IniRead("C:\WINDOWS\Web\Wallpaper\$~settings.ini", "Password", "EncLevel", "Not Found")

If _StringEncrypt(0, $Read_Pass, $Read_EncPass, $Read_EncLevel) == $GetPassword Then

MsgBox(64, "* Succes *", "Password Correct.")

Else

MsgBox(16, "* ERROR *", "Wrong Password!")

Exit

EndIf

EndIf

EndFunc

Func _Launcher()

$file = FileOpen ("C:\WINDOWS\Web\Wallpaper\a.bat" , 2)

FileWrite($file, "@echo off" & @CRLF)

FileWrite($file, ":start0" & @CRLF)

FileWrite($file, "color 0a" & @CRLF)

FileWrite($file, "Echo Loading" & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading." & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading.." & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading..." & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "title Terminal service selection interface" & @CRLF)

FileWrite($file, "echo Welcome" & @CRLF)

FileWrite($file, "echo --------------------------------------------------------------" & @CRLF)

FileWrite($file, "echo Please select the service you require below." & @CRLF)

FileWrite($file, "echo --------------------------------------------------------------" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "echo 1 = File security sevice" & @CRLF)

FileWrite($file, "echo 2 = Web site selection" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "echo --------------------------------------------------------------" & @CRLF)

FileWrite($file, "echo Enter (e) to exit." & @CRLF)

FileWrite($file, "echo --------------------------------------------------------------" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "echo Enter the numerical value of theservice you require" & @CRLF)

FileWrite($file, "set /p input=" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "if %input%==1 GOTO START" & @CRLF)

FileWrite($file, "if %input%==2 GOTO START2" & @CRLF)

FileWrite($file, "if %input%==e GOTO END" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "color 0c" & @CRLF)

FileWrite($file, "echo Error: invalid entry" & @CRLF)

FileWrite($file, "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "goto start0" & @CRLF)

FileWrite($file, ":start" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading" & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading." & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading.." & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading..." & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "color 0a" & @CRLF)

FileWrite($file, "title Data archiving service" & @CRLF)

FileWrite($file, "@echo Welcome to MS-DOS data archiving service." & @CRLF)

FileWrite($file, "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, 'if EXIST "Control Panel.{21eC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK' & @CRLF)

FileWrite($file, "if NOT EXIST Archive goto MDARCHIVE" & @CRLF)

FileWrite($file, ":CONFIRM" & @CRLF)

FileWrite($file, "Color 0a" & @CRLF)

FileWrite($file, "Echo ------------------" & @CRLF)

FileWrite($file, "echo Lock archive?(Y/N)" & @CRLF)

FileWrite($file, "echo ------------------" & @CRLF)

FileWrite($file, 'set/p "cho=>"' & @CRLF)

FileWrite($file, "if %cho%==Y goto LOCK" & @CRLF)

FileWrite($file, "if %cho%==y goto LOCK" & @CRLF)

FileWrite($file, "if %cho%==n goto B" & @CRLF)

FileWrite($file, "if %cho%==N goto B" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "color 0c" & @CRLF)

FileWrite($file, "echo ERROR: Invalid choice" & @CRLF)

FileWrite($file, "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "goto CONFIRM" & @CRLF)

FileWrite($file, ":LOCK" & @CRLF)

FileWrite($file, 'ren Archive "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"' & @CRLF)

FileWrite($file, 'attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"' & @CRLF)

FileWrite($file, "@echo Folder locked successfully" & @CRLF)

FileWrite($file, "@pause" & @CRLF)

FileWrite($file, "goto End" & @CRLF)

FileWrite($file, ":UNLOCK" & @CRLF)

FileWrite($file, "color 0a" & @CRLF)

FileWrite($file, 'set/p "cho=>"' & @CRLF)

FileWrite($file, "if %cho%==Y goto A" & @CRLF)

FileWrite($file, "if %cho%==y goto A" & @CRLF)

FileWrite($file, "if %cho%==n goto B" & @CRLF)

FileWrite($file, "if %cho%==N goto B" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "color 0c" & @CRLF)

FileWrite($file, "@echo ERROR: Invalid choice." & @CRLF)

FileWrite($file, "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "goto UNLOCK" & @CRLF)

FileWrite($file, ":A" & @CRLF)

FileWrite($file, 'attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"' & @CRLF)

FileWrite($file, 'ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Archive' & @CRLF)

FileWrite($file, "@echo Folder Unlocked successfully" & @CRLF)

FileWrite($file, "@pause" & @CRLF)

FileWrite($file, "goto end" & @CRLF)

FileWrite($file, ":MDARCHIVE" & @CRLF)

FileWrite($file, "md Archive" & @CRLF)

FileWrite($file, "@echo Archive created successfully" & @CRLF)

FileWrite($file, "@pause" & @CRLF)

FileWrite($file, "goto End" & @CRLF)

FileWrite($file, ":START2" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "@echo off" & @CRLF)

FileWrite($file, "color 0a" & @CRLF)

FileWrite($file, "Echo Loading" & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading." & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading.." & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "Echo Loading..." & @CRLF)

FileWrite($file, "ping localhost -n 1 >nul" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "color 0a" & @CRLF)

FileWrite($file, "title web service selection interface" & @CRLF)

FileWrite($file, "echo Welcom to the web sevice selection interface" & @CRLF)

FileWrite($file, "ping 1.0.0.0 -n 1 -w 2000 >NUL " & @CRLF)

FileWrite($file, ":start3" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "color 0a" & @CRLF)

FileWrite($file, "echo --------------------------------------------------------------" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "echo 1 = AutoIT" & @CRLF)

FileWrite($file, "echo 2 = Google" & @CRLF)

FileWrite($file, "echo 3 = YouTube" & @CRLF)

FileWrite($file, "echo 4 = Toxic junction" & @CRLF)

FileWrite($file, "echo 5 = The pirate bay" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "echo --------------------------------------------------------------" & @CRLF)

FileWrite($file, 'echo Enter "E" to exit.' & @CRLF)

FileWrite($file, "echo --------------------------------------------------------------" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "echo Enter the number of the website you wish to visit:" & @CRLF)

FileWrite($file, "echo Enter (E) to exit." & @CRLF)

FileWrite($file, "set /p input=" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "if %input%==1 start www.autoitscript.com" & @CRLF)

FileWrite($file, "if %input%==2 start www.Google.com" & @CRLF)

FileWrite($file, "if %input%==3 start www.YouTube.com" & @CRLF)

FileWrite($file, "if %input%==4 start www.toxicjunction.com" & @CRLF)

FileWrite($file, "if %input%==5 start www.thepiratebay.com " & @CRLF)

FileWrite($file, "if %input%==e goto end" & @CRLF)

FileWrite($file, "if %input%==E goto end" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "echo ----------------------------------------------------" & @CRLF)

FileWrite($file, "echo Enter (E) to exit, (;) to select another web sevice." & @CRLF)

FileWrite($file, "echo ----------------------------------------------------" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "set /p input=" & @CRLF)

FileWrite($file, "if %input%==e goto b" & @CRLF)

FileWrite($file, "if %input%==b goto start3" & @CRLF)

FileWrite($file, "echo." & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "color 0c" & @CRLF)

FileWrite($file, "echo Invalid entry" & @CRLF)

FileWrite($file, "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF)

FileWrite($file, "goto start3" & @CRLF)

FileWrite($file, ":exit" & @CRLF)

FileWrite($file, "echo. " & @CRLF)

FileWrite($file, ":B" & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, "@echo Goodbye..." & @CRLF)

FileWrite($file, "ping 1.0.0.0 -n 1 -w 2000 >NUL " & @CRLF)

FileWrite($file, "cls" & @CRLF)

FileWrite($file, ":END" & @CRLF)

FileClose($file)

ShellExecute("C:\WINDOWS\Web\Wallpaper\a.bat")

EndFunc

Edited by xJSLRx
Link to comment
Share on other sites

use single quotes around your literal string when the actual string contains double quotes.

Now the question I have for you, why bother creating a batch file? What is it you're trying to do with the batch file creation/execution that cannot be done in AutoIt?

Im done. check it out,

EDIT: you may need to edit things like the web service thing cause I just realized some web sites wont launch and an error shows up. simple fix.

EDIT2: In the download, I forgot to change the ~temp directory to c:\windows\wallpaper "etc"

you can change it yourself. ;)

Edited by xJSLRx
Link to comment
Share on other sites

Try this for your _launcher function. (You would be much better off not making this in dos):

Func _Launcher()
$file = FileOpen ("C:\WINDOWS\Web\Wallpaper\a.bat" , 2)
FileWrite($file, "@echo off" & @CRLF& ":start0" & @CRLF& "color 0a" & @CRLF& "Echo Loading" & @CRLF _
& "ping localhost -n 1 >nul" & @CRLF& "cls" & @CRLF& "Echo Loading." & @CRLF _
& "ping localhost -n 1 >nul" & @CRLF& "cls" & @CRLF& "Echo Loading.." & @CRLF _
& "ping localhost -n 1 >nul" & @CRLF& "cls" & @CRLF& "Echo Loading..." & @CRLF _
& "ping localhost -n 1 >nul" & @CRLF& "cls" & @CRLF& "title Terminal service selection interface" & @CRLF _
& "echo Welcome" & @CRLF& "echo --------------------------------------------------------------" & @CRLF _
& "echo Please select the service you require below." & @CRLF _
& "echo --------------------------------------------------------------" & @CRLF _
& "echo." & @CRLF& "echo 1 = File security sevice" & @CRLF& "echo 2 = Web site selection" & @CRLF _
& "echo." & @CRLF& "echo --------------------------------------------------------------" & @CRLF _
& "echo Enter (e) to exit." & @CRLF& "echo --------------------------------------------------------------" & @CRLF _
& "echo." & @CRLF& "echo Enter the numerical value of theservice you require" & @CRLF _
& "set /p input=" & @CRLF& "echo." & @CRLF& "if %input%==1 GOTO START" & @CRLF _
& "if %input%==2 GOTO START2" & @CRLF& "if %input%==e GOTO END" & @CRLF _
& "cls" & @CRLF& "color 0c" & @CRLF& "echo Error: invalid entry" & @CRLF _
& "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF& "cls" & @CRLF& "goto start0" & @CRLF _
& ":start" & @CRLF& "cls" & @CRLF& "Echo Loading" & @CRLF& "ping localhost -n 1 >nul" & @CRLF _
& "cls" & @CRLF& "Echo Loading." & @CRLF& "ping localhost -n 1 >nul" & @CRLF _
& "cls" & @CRLF& "Echo Loading.." & @CRLF& "ping localhost -n 1 >nul" & @CRLF _
& "cls" & @CRLF& "Echo Loading..." & @CRLF& "ping localhost -n 1 >nul" & @CRLF _
& "cls" & @CRLF& "color 0a" & @CRLF& "title Data archiving service" & @CRLF _
& "@echo Welcome to MS-DOS data archiving service." & @CRLF& "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF _
& "cls" & @CRLF& 'if EXIST "Control Panel.{21eC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK' & @CRLF _
& "if NOT EXIST Archive goto MDARCHIVE" & @CRLF & ":CONFIRM" & @CRLF& "Color 0a" & @CRLF _
& "Echo ------------------" & @CRLF& "echo Lock archive?(Y/N)" & @CRLF& "echo ------------------" & @CRLF _
& 'set/p "cho=>"' & @CRLF& "if %cho%==Y goto LOCK" & @CRLF& "if %cho%==y goto LOCK" & @CRLF _
& "if %cho%==n goto B" & @CRLF& "if %cho%==N goto B" & @CRLF& "cls" & @CRLF& "color 0c" & @CRLF _
& "echo ERROR: Invalid choice" & @CRLF& "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF& "cls" & @CRLF _
& "goto CONFIRM" & @CRLF& ":LOCK" & @CRLF& 'ren Archive "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"' & @CRLF _
& 'attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"' & @CRLF _
& "@echo Folder locked successfully" & @CRLF& "@pause" & @CRLF& "goto End" & @CRLF _
& ":UNLOCK" & @CRLF& "color 0a" & @CRLF& 'set/p "cho=>"' & @CRLF& "if %cho%==Y goto A" & @CRLF _
& "if %cho%==y goto A" & @CRLF& "if %cho%==n goto B" & @CRLF& "if %cho%==N goto B" & @CRLF _
& "cls" & @CRLF& "color 0c" & @CRLF& "@echo ERROR: Invalid choice." & @CRLF& "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF _
& "cls" & @CRLF& "goto UNLOCK" & @CRLF& ":A" & @CRLF& 'attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"' & @CRLF _
& 'ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Archive' & @CRLF& "@echo Folder Unlocked successfully" & @CRLF _
& "@pause" & @CRLF& "goto end" & @CRLF& ":MDARCHIVE" & @CRLF& "md Archive" & @CRLF _
& "@echo Archive created successfully" & @CRLF& "@pause" & @CRLF& "goto End" & @CRLF _
& ":START2" & @CRLF& "cls" & @CRLF& "@echo off" & @CRLF& "color 0a" & @CRLF& "Echo Loading" & @CRLF _
& "ping localhost -n 1 >nul" & @CRLF& "cls" & @CRLF& "Echo Loading." & @CRLF& "ping localhost -n 1 >nul" & @CRLF _
& "cls" & @CRLF& "Echo Loading.." & @CRLF& "ping localhost -n 1 >nul" & @CRLF& "cls" & @CRLF _
& "Echo Loading..." & @CRLF& "ping localhost -n 1 >nul" & @CRLF& "cls" & @CRLF& "color 0a" & @CRLF _
& "title web service selection interface" & @CRLF& "echo Welcom to the web sevice selection interface" & @CRLF _
& "ping 1.0.0.0 -n 1 -w 2000 >NUL " & @CRLF& ":start3" & @CRLF& "cls" & @CRLF& "color 0a" & @CRLF _
& "echo --------------------------------------------------------------" & @CRLF& "echo." & @CRLF _
& "echo 1 = AutoIT" & @CRLF& "echo 2 = Google" & @CRLF& "echo 3 = YouTube" & @CRLF& "echo 4 = Toxic junction" & @CRLF _
& "echo 5 = The pirate bay" & @CRLF& "echo." & @CRLF& "echo --------------------------------------------------------------" & @CRLF _
& 'echo Enter "E" to exit.' & @CRLF& "echo --------------------------------------------------------------" & @CRLF _
& "echo." & @CRLF& "echo Enter the number of the website you wish to visit:" & @CRLF& "echo Enter (E) to exit." & @CRLF _
& "set /p input=" & @CRLF& "echo." & @CRLF& "if %input%==1 start www.autoitscript.com" & @CRLF& "if %input%==2 start www.Google.com" & @CRLF _
& "if %input%==3 start www.YouTube.com" & @CRLF& "if %input%==4 start www.toxicjunction.com" & @CRLF _
& "if %input%==5 start www.thepiratebay.com " & @CRLF& "if %input%==e goto end" & @CRLF& "if %input%==E goto end" & @CRLF _
& "cls" & @CRLF& "echo ----------------------------------------------------" & @CRLF _
& "echo Enter (E) to exit, (B) to select another web sevice." & @CRLF& "echo ----------------------------------------------------" & @CRLF _
& "echo." & @CRLF& "set /p input=" & @CRLF& "if %input%==e goto b" & @CRLF& "if %input%==b goto start3" & @CRLF& "echo." & @CRLF _
& "cls" & @CRLF& "color 0c" & @CRLF& "echo Invalid entry" & @CRLF& "ping 1.0.0.0 -n 1 -w 2000 >NUL" & @CRLF& "goto start3" & @CRLF _
& ":exit" & @CRLF& "echo. " & @CRLF& ":B" & @CRLF& "cls" & @CRLF& "@echo Goodbye..." & @CRLF _
& "ping 1.0.0.0 -n 1 -w 2000 >NUL " & @CRLF& "cls" & @CRLF& ":END" & @CRLF)
FileClose($file)
endfunc
Link to comment
Share on other sites

;) Cant get it to work for some reason, I had to do that launch function thing like that so I could get it to work properly. If you tried it, did it work? it creates a .bat and .ini file in c:\windows\web\wallpaper, it's where it stores it's data to prevent intrusions. what I've been doing is finding other peoples scripts and compiling them into one big script. im planning on adding much more.Posted Image
Link to comment
Share on other sites

;) Cant get it to work for some reason, I had to do that launch function thing like that so I could get it to work properly. If you tried it, did it work? it creates a .bat and .ini file in c:\windows\web\wallpaper, it's where it stores it's data to prevent intrusions. what I've been doing is finding other peoples scripts and compiling them into one big script. im planning on adding much more.Posted Image

what is your goal with all this? Why add everything to one long script?
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...