Page 1 of 1 1
Topic Options
#150467 - 2005-10-24 05:15 PM File Attribute and MOVE problem.
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
Can anyone identify why the rename process does not work. I am having to use the CMD line to post process .new to .ini...
Code:
  
break on
$SD=%SystemDrive%
$ATTR = GETFILEATTR('$SD + "\boot.ini"')
IF Open(1, $SD + "\boot.ini",2) = 0
If exist($SD + "\boot.new")
del '$SD + "\boot.new"' /c /f /h
endif
IF Open(2, $SD + "\boot.new",5) = 0
$IN = readline(1)
While Not @ERROR
if left($IN,5) = "multi" and right($IN,3) <> "3gb"
$array = split($IN,'"',-1)
$OUT = WRITELINE (2,$array[0]+'"'+$array[1]+' /3gb"'+$array[2]+' /3gb'+ @CRLF)
$OUT = WRITELINE (2,$IN + @CRLF)
else
if left($IN,8) = "timeout=" $IN = "timeout=10" endif
$OUT = WRITELINE (2,$IN + @CRLF)
endif
$IN = readline(1)
loop
close (2)
close (1)
If exist($SD + "\boot-old.ini")
del '$SD + "\boot-old.ini"' /c /f /h
endif
if ($x = SETFILEATTR('$SD + "\boot.ini"',128)) = 0
move '$SD + "\boot.ini"' '$SD + "\boot-old.ini"' /h /r
if @error = 0
move '$SD + "\boot.new"' '$SD + "\boot.ini"' /h /r
$x = SETFILEATTR('$SD + "\boot.ini"',$ATTR)
endif
endif
endif
endif


Top
#150468 - 2005-10-24 06:46 PM Re: File Attribute and MOVE problem.
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Your move statement has quotes in the wrong places:

They should be like this:
Code:
 
move $SD + "\boot.ini" $SD + "\boot-old.ini" /h /r



When constructing your strings, the $SD + "\boot.ini" become one string of "C:\boot.ini". When you placed the $SD and the "\Boot.ini" inside single quotes, the source string became C:"\boot.ini" , and this generated an illegal file name.

If you belive that your filespec would have spaces in it, you should use something like:
Code:
 
Move '"' + $SD + '\some file with spaces.txt"'


This is interpreted as "C:\some file with spaces.txt"

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#150469 - 2005-10-24 08:11 PM Re: File Attribute and MOVE problem.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
actually, his move line:
Code:

move '$SD + "\boot.ini"' '$SD + "\boot-old.ini"' /h /r



becomes:
Code:

move 'C: + "\boot.ini"' 'C: + "\boot-old.ini"' /h /r


and thus, the final source is not C:"\boot.ini" but: C: + "\boot.ini"
_________________________
!

download KiXnet

Top
#150470 - 2005-10-24 09:39 PM Re: File Attribute and MOVE problem.
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
er, right! I'm making up for the lack of caffiene as we speak!

Either way, it's a name that doesn't represent the file he's trying to access.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#150471 - 2005-10-25 02:09 PM Re: File Attribute and MOVE problem.
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
Thanks all, it was the single quotes. Still takes some getting used to how it parses the line... Final code.
Code:
  
break on
if $ram < 1024
messagebox("Insufficient System RAM","ABORTED",16,10)
exit
endif
$SD=%SystemDrive%
IF Open(1, $SD + "\boot.ini",2) = 0
If exist($SD + "\boot.new")
del '$SD + "\boot.new"' /c /f /h
endif
IF Open(2, $SD + "\boot.new",5) = 0
$IN = readline(1)
While Not @ERROR
if left($IN,5) = "multi" and right($IN,3) = "3gb"
close (2)
close (1)
del $SD + "\boot.new" /c /f /h
messagebox("ALREADY installed","ABORTED",16,10)
exit
else
if left($IN,5) = "multi" and right($IN,3) <> "3gb"
$array = split($IN,'"',-1)
$OUT = WRITELINE (2,$array[0]+'"'+$array[1]+' /3gb"'+$array[2]+' /3gb'+ @CRLF)
$OUT = WRITELINE (2,$IN + @CRLF)
else
if left($IN,8) = "timeout=" $IN = "timeout=10" endif
$OUT = WRITELINE (2,$IN + @CRLF)
endif
$IN = readline(1)
endif
loop
close (2)
close (1)
If exist($SD + "\boot-old.ini")
del $SD + "\boot-old.ini" /c /f /h
endif
$x = SETFILEATTR($SD + "\boot.ini",128)
move $SD + "\boot.ini" $SD + "\boot-old.ini" /h /r
if @error = 0
move $SD + "\boot.new" $SD + "\boot.ini" /h /r
$x = SETFILEATTR($SD + "\boot.ini",7)
$x = SETFILEATTR($SD + "\boot-old.ini",3)
endif
? "=" + $ATTR
messagebox("INSTALLED","3Gb Switch",64,10)
endif
endif


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
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.065 seconds in which 0.037 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