I'm looking for a script that will allow me to set the path (in the
autoexec.bat file for the 9x world) and in the SYSTEM environment in
the NT world.

I've tried several things and can get the NT world to work, ut have
had no luck in setting the path in the 9x world (autoexec.bat).

Can someone show me the way?

Thanks!

Ron

RE: Environment Path (Win9x & WinXP) by tlavedas

tlavedas
Wed Jun 23 08:18:01 CDT 2004

Maybe something like this ...

'------------------- 8< ------------------------
' For Win 9x equipped machines only
Const sAddPath = "c:\SOME\location" ' << you set this <<
Const ForReading= 1, ForAppending = 8
Const sFileSpec = "C:\autoexec.bat"
set FSO = CreateObject("Scripting.FileSystemObject")
if FSO.FileExists(sFileSpec) Then
nOldAttrib = FSO.GetFile(sFileSpec).Attributes
FSO.GetFile(sFileSpec).Attributes = 0
sLines = FSO.OpenTextFile(sFileSpec, ForReading).ReadAll
For each sLine in Split(sLines, vbNewline)
if InStr(1, sLine, sAddPath, vbTextCompare) <> 0 then
' If path is already present, just quite routine
wscript.Quit
End if
Next
End if
FSO.OpenTextFile(sFileSpec, ForAppending, True)_
.WriteLine vbNewline & "path %path%;" & sAddPath
if nOldAttrib <> 0 Then _
FSO.GetFile(sFileSpec).Attributes = nOldAttrib
'------------------- End ------------------------

Tom Lavedas
===========


"Ron Saxer" wrote:

> I'm looking for a script that will allow me to set the path (in the
> autoexec.bat file for the 9x world) and in the SYSTEM environment in
> the NT world.
>
> I've tried several things and can get the NT world to work, ut have
> had no luck in setting the path in the 9x world (autoexec.bat).
>
> Can someone show me the way?
>
> Thanks!
>
> Ron
>

RE: Environment Path (Win9x & WinXP) by tlavedas

tlavedas
Wed Jun 23 12:21:01 CDT 2004

Sorry, just noticed an error. The last If statement should be ...

if not IsEmpty(nOldAttrib) Then _
FSO.GetFile(sFileSpec).Attributes = nOldAttrib

Tom Lavedas
===========

"Tom Lavedas" wrote:

> Maybe something like this ...
>
> '------------------- 8< ------------------------
> ' For Win 9x equipped machines only
> Const sAddPath = "c:\SOME\location" ' << you set this <<
> Const ForReading= 1, ForAppending = 8
> Const sFileSpec = "C:\autoexec.bat"
> set FSO = CreateObject("Scripting.FileSystemObject")
> if FSO.FileExists(sFileSpec) Then
> nOldAttrib = FSO.GetFile(sFileSpec).Attributes
> FSO.GetFile(sFileSpec).Attributes = 0
> sLines = FSO.OpenTextFile(sFileSpec, ForReading).ReadAll
> For each sLine in Split(sLines, vbNewline)
> if InStr(1, sLine, sAddPath, vbTextCompare) <> 0 then
> ' If path is already present, just quite routine
> wscript.Quit
> End if
> Next
> End if
> FSO.OpenTextFile(sFileSpec, ForAppending, True)_
> .WriteLine vbNewline & "path %path%;" & sAddPath
> if nOldAttrib <> 0 Then _
> FSO.GetFile(sFileSpec).Attributes = nOldAttrib
> '------------------- End ------------------------
>
> Tom Lavedas
> ===========
>
>
> "Ron Saxer" wrote:
>
> > I'm looking for a script that will allow me to set the path (in the
> > autoexec.bat file for the 9x world) and in the SYSTEM environment in
> > the NT world.
> >
> > I've tried several things and can get the NT world to work, ut have
> > had no luck in setting the path in the 9x world (autoexec.bat).
> >
> > Can someone show me the way?
> >
> > Thanks!
> >
> > Ron
> >

Re: Environment Path (Win9x & WinXP) by Ron

Ron
Thu Jun 24 09:35:15 CDT 2004

Thanks Tom for pointing me in the right direction. This really helped!

Ron

On Wed, 23 Jun 2004 10:21:01 -0700, "Tom Lavedas"
<tlavedas@hotmail.remove.com> wrote:

>Sorry, just noticed an error. The last If statement should be ...
>
>if not IsEmpty(nOldAttrib) Then _
> FSO.GetFile(sFileSpec).Attributes = nOldAttrib
>
>Tom Lavedas
>===========
>
>"Tom Lavedas" wrote:
>
>> Maybe something like this ...
>>
>> '------------------- 8< ------------------------
>> ' For Win 9x equipped machines only
>> Const sAddPath = "c:\SOME\location" ' << you set this <<
>> Const ForReading= 1, ForAppending = 8
>> Const sFileSpec = "C:\autoexec.bat"
>> set FSO = CreateObject("Scripting.FileSystemObject")
>> if FSO.FileExists(sFileSpec) Then
>> nOldAttrib = FSO.GetFile(sFileSpec).Attributes
>> FSO.GetFile(sFileSpec).Attributes = 0
>> sLines = FSO.OpenTextFile(sFileSpec, ForReading).ReadAll
>> For each sLine in Split(sLines, vbNewline)
>> if InStr(1, sLine, sAddPath, vbTextCompare) <> 0 then
>> ' If path is already present, just quite routine
>> wscript.Quit
>> End if
>> Next
>> End if
>> FSO.OpenTextFile(sFileSpec, ForAppending, True)_
>> .WriteLine vbNewline & "path %path%;" & sAddPath
>> if nOldAttrib <> 0 Then _
>> FSO.GetFile(sFileSpec).Attributes = nOldAttrib
>> '------------------- End ------------------------
>>
>> Tom Lavedas
>> ===========
>>
>>
>> "Ron Saxer" wrote:
>>
>> > I'm looking for a script that will allow me to set the path (in the
>> > autoexec.bat file for the 9x world) and in the SYSTEM environment in
>> > the NT world.
>> >
>> > I've tried several things and can get the NT world to work, ut have
>> > had no luck in setting the path in the 9x world (autoexec.bat).
>> >
>> > Can someone show me the way?
>> >
>> > Thanks!
>> >
>> > Ron
>> >