Modify

Opened 15 years ago

Closed 15 years ago

#1904 closed Bug (Works For Me)

Problem with @MyDocumentsDir macro in Windows XP

Reported by: ffdshow Owned by:
Milestone: Component: AutoIt
Version: 3.3.6.1 Severity: None
Keywords: Cc:

Description

If I run the code bellow in Windows XP SP3 ENG, @MyDocumentsDir macro returns C:\Documents and Settings\User Name\Documents instead of C:\Documents and Settings\User Name\My Documents
and StrongDC++ will create after the first run a folder named Documents in %userprofile%

$InputFile = @MyDocumentsDir & '\StrongDC++' & '\DCPlusPlus.xml'
$str2Find = 'C:\Users\User Name\Documents'
$str2Replace = @MyDocumentsDir
$file = FileOpen($InputFile, 0)
If $file <> -1 Then
	$fc = FileRead($file)
	$fc = StringReplace($fc, $str2Find, $str2Replace)
	FileClose($file)
	$file = FileOpen($InputFile, 2)
	FileWrite($file, $fc)
	FileClose($file)
Else
	Exit
EndIf

The above code work well in Windows 7.
FileCopy and DirCopy commands with @MyDocumentsDir macro parameter run correctly in Windows XP SP3 ENG. Also, a script like this:

MsgBox(0,0, @MyDocumentsDir)

gives the right path in Windows XP.

Attachments (1)

DCPlusPlus.xml (17.2 KB ) - added by ffdshow 15 years ago.
StrongDC++ settings file

Download all attachments as: .zip

Change History (5)

comment:1 by mvg, 15 years ago

None reproducible, on clean windows (in virtual box)
Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 3 CPU:X86 OS:X86)

Suspect local Windows settings issue, As @MyDocumentsDir (or the "My documents" folder location) is a User-changeable windows setting!

by ffdshow, 15 years ago

Attachment: DCPlusPlus.xml added

StrongDC++ settings file

comment:2 by ffdshow, 15 years ago

This script gives the error from first post:

$Installer = "sdc242-32.exe"
RunWait($Installer & " /S")
; Copy the settings folder
DirCopy(@ScriptDir & "\StrongDC++", @MyDocumentsDir & "\StrongDC++", 1)
; Edit DCPlusPlus.xml file
$InputFile = @MyDocumentsDir & "\StrongDC++" & "\DCPlusPlus.xml"
$str2Find = "C:\Users\Power User"
$str2Replace = @UserProfileDir
$file = FileOpen($InputFile, 0)
If $file <> -1 Then
	$fc = FileRead($file)
	$fc = StringReplace($fc, $str2Find, $str2Replace)
	FileClose($file)
	$file = FileOpen($InputFile, 2)
	FileWrite($file, $fc)
	FileClose($file)
Else
	Exit
EndIf
$InputFilez = @MyDocumentsDir & "\StrongDC++" & "\DCPlusPlus.xml"
$str2Findz = "C:\Users\Power User\Documents"
$str2Replacez = @MyDocumentsDir
$filez = FileOpen($InputFilez, 0)
If $filez <> -1 Then
	$fcz = FileRead($filez)
	$fcz = StringReplace($fcz, $str2Findz, $str2Replacez)
	FileClose($filez)
	$file = FileOpen($InputFilez, 2)
	FileWrite($filez, $fcz)
	FileClose($filez)
Else
	Exit
EndIf

In this one I changed the order of edit operations on DCPlusPlus.xml file and the error is gone:

$Installer = "sdc242-32.exe"
RunWait($Installer & " /S")
; Copy the settings folder
DirCopy(@ScriptDir & "\StrongDC++", @MyDocumentsDir & "\StrongDC++", 1)
; Edit DCPlusPlus.xml file
$InputFilez = @MyDocumentsDir & "\StrongDC++" & "\DCPlusPlus.xml"
$str2Findz = "C:\Users\Power User\Documents"
$str2Replacez = @MyDocumentsDir
$filez = FileOpen($InputFilez, 0)
If $filez <> -1 Then
	$fcz = FileRead($filez)
	$fcz = StringReplace($fcz, $str2Findz, $str2Replacez)
	FileClose($filez)
	$file = FileOpen($InputFilez, 2)
	FileWrite($filez, $fcz)
	FileClose($filez)
Else
	Exit
EndIf
$InputFile = @MyDocumentsDir & "\StrongDC++" & "\DCPlusPlus.xml"
$str2Find = "C:\Users\Power User"
$str2Replace = @UserProfileDir
$file = FileOpen($InputFile, 0)
If $file <> -1 Then
	$fc = FileRead($file)
	$fc = StringReplace($fc, $str2Find, $str2Replace)
	FileClose($file)
	$file = FileOpen($InputFile, 2)
	FileWrite($file, $fc)
	FileClose($file)
Else
	Exit
EndIf

What part from the first script cause the error ?

comment:3 by mvg, 15 years ago

Erm. That's definitively not doing it for me.
Suggest you try the forum, as I think this is just a User-problem instead of a possible AutoIt-Bug.

comment:4 by Valik, 15 years ago

Resolution: Works For Me
Status: newclosed

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.