Jump to content

adding a line to several batchfiles


Recommended Posts

Hi all

I have about 60 logon scripts runningon two domains which whenever I deploy a script to the users I have to edit each one manually.

I thought why not write a script that will add a line of text to each script. The .bat file structure is:

@echo off

Rem (scripts I have written)

\\Share\file1.exe

\\Share\file2.exe

\\Share\file3.exe

rest of script

Where I'm struggling is.. how do I add the line to the other scripts. I can add it to the end but I want the scripts to run before drives are mapped etc

Here's what I have so far:

CODE
$search = FileFindFirstFile("c:\test\batch\*.bat")

; Check if the search was successful

If $search = -1 Then

MsgBox(0, "Error", "No files/directories matched the search pattern")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

FileOpen($file, 1)

FileWriteLine($file, "test")

MsgBox(4096, "File:", $file)

WEnd

; Close the search handle

FileClose($search)

anybody have any ideas?

thanks for looking

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Link to comment
Share on other sites

My suggestion is to read each file with _FileReadToArray()

Figure out where in each file you want to insert your commands. (How do you identify where "drives are mapped etc"?)

Then use _FileWriteToLine() or _ArrayInsert() + _FileWriteFromArray()

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

Hmm.. you used the 'A' word. I have no absolutely experience with working with arrays and to be honest I dont understand quite how they work.

Is there another other way or can anyone offer some advice on how to use arrays (I have a feeling I should learn more about them but I have no idea where to start)

Thanks

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

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