Page 1 of 1 1
Topic Options
#7056 - 2001-02-22 10:09 AM Writing lines to Autoexec.bat
Anonymous
Unregistered


Hi thanks for all the help so far! I want to be able to write lines to the Autoexec.bat file on Win95 clients I was wanting to use:

IF INGROUP ("TESTING-GRP")
OPEN( 2 ,"c:Autoexec.bat" , 4)

$x = WriteLine( 2 , “KiXtart started at ” + @TIME + Chr(13) + Chr(10) )

ELSE

BEEP

? "failed to open file, error code : [" + @ERROR + "]"

ENDIF

Does this look right also how would you handle writing multiple lines?

Top
#7057 - 2001-02-22 01:08 PM Re: Writing lines to Autoexec.bat
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Hi Halo,

The correct code should look something like:

IF INGROUP ("TESTING-GRP")
if open( 2 ,"c:\Autoexec.bat" , 4)=0
$x = WriteLine( 2 , "KiXtart started at " + @TIME + Chr(13) + Chr(10) )
close (2)
else
beep
? "failed to open file, error code : [" + @ERROR + "]"
endif
ENDIF

But why do yo want to write a line like that to the autoexec.bat?

------------------
Greetz,

Roger the Young
------------------------
The code is out there...
------------------------

[This message has been edited by DrillSergeant (edited 22 February 2001).]

_________________________
The Code is out there

Top
#7058 - 2001-02-22 02:02 PM Re: Writing lines to Autoexec.bat
Anonymous
Unregistered


Your right I would not want to write that to the autoexec.bat file. I want to append some code to the autoexec.bat files for my Windows 95 clients. So far I have:

-----------------------------------------
From the kixtart script:

IF INGROUP ("TESTING-GRP")
RUN "NET USE Z: /DELETE /Y"
RUN "NET USE Z: \\AITSPC12\DEL"
CAll "delete.bat"
ENDIF

------------------------------------------

Delete.bat file:

if exist c:del.chk goto end
endif

if exist c:autoexec.bat ren c:autoexec.bat c:del.chk

$auto=""
open(1,"c:\autoexec.bat")
$line=readline(1)
while @ERROR=0
$string=$string+$line
$line=readline(1)
loop
$null=close(1)

$delstuff=""
open(1,"z:\del\delete.txt")
$line=readline(1)
while @ERROR=0
$string=$string+$line
$line=readline(1)
loop
$null=close(1)

$newaut= $auto + $delstuff

open( 2 ,"c:\Autoexec.bat" , 4)=0
$x = WriteLine( 2 , $newaut )
close (2)
-------------------------------------------

Now the only thing I am usure of is if writeline will write the file.

Top
#7059 - 2001-02-22 02:15 PM Re: Writing lines to Autoexec.bat
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
I take it, you want to map z: for use in win9x systems?

Bryce

Top
#7060 - 2001-02-22 04:07 PM Re: Writing lines to Autoexec.bat
Anonymous
Unregistered


That's a point! I have tried when running my tests using: open(1,"c:\delete.txt") but this still does not work and I have fixed the little errors the script now looks like this:

------------------------------------------

if exist c:\del.chk goto end
endif

if exist c:\autoexec.bat copy c:\autoexec.bat c:\del.chk

$auto=""
open(1,"c:\autoexec.bat")
$line=readline(1)
while @ERROR=0
$auto=$auto+$line
$line=readline(1)
loop
$null=close(1)

$delstuff=""
open(1,"c:\delete.txt")
$line=readline(1)
while @ERROR=0
$delstuff=$delstuff+$line
$line=readline(1)
loop
$null=close(1)

$newaut=$auto+$delstuff

open( 2 ,"c:\autotest.bat" , 1)=0
$x = WriteLine( 2 , $newaut )
close (2)


ENDIF

:end

--------------------------------------------

The problem is I am getting script failure errors that are too fast to read. When performing a call what file type should this be? If I save the above to a batch file and run it it I get errors.

Top
#7061 - 2001-02-22 04:22 PM Re: Writing lines to Autoexec.bat
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
HaloBurn,

lets take a step back for a moment.

A kix script and a batch file are to very different things.

Normally a kix script will end in a .kix or a .scr extension. To run a kix script you need the file kix32.exe and your run it like this "kix32.exe kixscript.kix"


Now lets leave the code out of this for the moment, and tell us what goal you are trying to achieve.

Bryce

------------------
kix.isorg.net

Top
#7062 - 2001-02-22 04:35 PM Re: Writing lines to Autoexec.bat
Anonymous
Unregistered


Ok sorry I realise I think i am getting a bit confused! we run Kix32 as part of a users profile during logon this calls Kixtart.scr within this script I have added a call to delete.scr. I want to add the following lines to the client PC's autoexec.bat file:

deltree /y c:\temp\.
deltree /y c:\windows\recent\.
deltree /y c:\windows\temp\.
deltree /y c:\windows\tempor~1\.
if not exist c:\temp\nul mkdir c:\temp
if not exist c:\windows\recent\nul mkdir c:\windows\recent
if not exist c:\windows\temp\nul mkdir c:\windows\temp

This is so that everytime the user starts the PC up all the temp files are deleted.

Top
#7063 - 2001-02-22 05:53 PM Re: Writing lines to Autoexec.bat
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
All,

I just updated the post in Scripts before I found this..

HaloBurn,

Why not use the KiX script to do the deleting? You can run the DOS commands like this:

shell "%comspec% /c deltree /y blah"

KiX supports the MD command and does not return screen errors if the dir already exists.

cj

------------------
For more scripts goto my website and click the hammer and spanner icon.

chrismat@ozemail.com.au


 

[This message has been edited by cj (edited 22 February 2001).]

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 781 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.055 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org