Modify

Opened 9 years ago

Closed 9 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 9 years ago.
StrongDC++ settings file

Download all attachments as: .zip

Change History (5)

comment:1 Changed 9 years ago by mvg

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!

Changed 9 years ago by ffdshow

StrongDC++ settings file

comment:2 Changed 9 years ago by ffdshow

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 Changed 9 years ago by mvg

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 Changed 9 years ago by Valik

  • Resolution set to Works For Me
  • Status changed from new to closed

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.