Jump to content

folder copy


bluerein
 Share

Recommended Posts

I need to copy the contents of a folder thats in the scriptdir called \models to a folder on the desktop that exists called \models

I cant get anything to work

last atempt was this

$origdirect = @ScriptDir &"\models\*.*"
$copydirect = @DesktopDir&"\models\"

FileMove($origdirect, $copydirect, 1)

also is there away to include a folder when compiling??

Link to comment
Share on other sites

You can only include files from what I know....

Try using:

DirMove

I've made a small app that ues FileMove and DirMove, maybe you'll find it usefull.

It's not totally finished but it works...

Press Options

Put first directory in the source and the second in the destination, (Also drag & drop) check the options (Files only etc) and press Ok then press Move

Here is the code, just run the code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#NoTrayIcon

Opt("GUIOnEventMode", 1)
Opt("OnExitFunc", "Quit")

Global $MainGUI, $SecGUI, $DropGUI, $SourceInput, $SourceRead, $DestinationInput
Global $DestinationRead, $Check1, $Check2, $Radio1, $Radio2, $Countpaths, $ExtInput, $ExtLabel
Global $InputData, $CheckPathCount, $CheckSplit, $SourcePath, $Focused

GUICreation()

While 1
    Sleep(1000)
WEnd

Func OnAutoItStart()
    If @compiled = 1 Then
        If @ScriptName <> "CopyFiles.exe" Then
            MsgBox(262160, "Error (Filename)", "Filename has been changed, the program will not run")
            Exit
        EndIf
    Else
        If _Singleton(@ScriptName, 1) = 0 Then
            MsgBox(262160, "Error (Already Running)", "This program is already running, only one instance is allowed!")
            Exit
        EndIf
        If FileExists(@ScriptDir & "\Settings.ini") = 0 Then
            FileInstall("E:\Settings.ini", @ScriptDir & "\Settings.ini")
        EndIf
    EndIf
    ReduceMemory()
EndFunc   ;==>OnAutoItStart

Func ReduceMemory($i_PID = -1)
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    Return $ai_Return[0]
EndFunc   ;==>ReduceMemory

Func GUICreation()
    $AlwaysOnTop = IniRead(@ScriptDir & "\Settings.ini", "Options", "AlwaysOnTop", "NotFound")
    $MainGUI = GUICreate("CopyFiles", 140, 92, Default, Default, 0, $WS_EX_TOOLWINDOW)
    $Copyfiles = GUICtrlCreateButton("Copy", 5, 5, 60, 25)
    GUICtrlSetOnEvent($Copyfiles, "Copy")
    $Movefiles = GUICtrlCreateButton("Move", 5, 35, 60, 25)
    GUICtrlSetOnEvent($Movefiles, "Move")
    $ProgramOptions = GUICtrlCreateButton("Options", 70, 5, 60, 25)
    GUICtrlSetOnEvent($ProgramOptions, "Options")
    $Exit = GUICtrlCreateButton("Exit", 70, 35, 60, 25)
    GUICtrlSetOnEvent($Exit, "Quit")
    If $AlwaysOnTop = 1 Then
        WinSetOnTop($MainGUI, "", 1)
    Else
        WinSetOnTop($MainGUI, "", 0)
    EndIf
    GUISetState(@SW_SHOW)
EndFunc   ;==>GUICreation

Func Copy()
    Local $CopyError = 0
    $SourcePath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "SourcePath", "NotFound")
    If $SourcePath = "" Then
        SourcePathEmpty()
    Else
        FileChangeDir($SourcePath)
        $CheckSplit = StringSplit($SourcePath, ",")
        If @error = 1 Then
            $Path = FileExists($CheckSplit[1])
            If $Path = 0 Then
                SourcePathInvalid1()
            Else
                CopyFiles()
            EndIf
        Else
            For $CheckPathCount = 1 To $CheckSplit[0]
                $Path = FileExists($CheckSplit[$CheckPathCount])
                If $Path = 0 Then
                    SourcePathInvalid2($CheckPathCount)
                    $CopyError = $CopyError + 1
                EndIf
            Next
            If $CopyError = 0 Then
                CopyFiles()
            EndIf
        EndIf
    EndIf
EndFunc   ;==>Copy

Func CopyFiles()
    $Ext = IniRead(@ScriptDir & "\Settings.ini", "Options", "Extension", "*.*")
    $Search1 = FileFindFirstFile("*.*")
    If $Search1 = -1 Then
        FileClose($Search1)
        FolderEmpty()
    Else
        FileClose($Search1)
        $Search2 = FileFindFirstFile($Ext)
        If $Search2 = -1 Then
            FileClose($Search2)
            NoExt()
        Else
            FileClose($Search2)
            $DestinationPath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "DestinationPath", "NotFound")
            If $DestinationPath = "" Then
                DestinationPathEmpty()
            Else
                $Overwrite = IniRead(@ScriptDir & "\Settings.ini", "Options", "Overwrite", "NotFound")
                $FilesOnly = IniRead(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", "NotFound")
                $SplitSource = StringSplit($SourcePath, ",")
                If @error = 1 Then
                    If $FilesOnly = 1 Then
                        FileCopy($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        MsgBox(262144, "Success", "File copy operation was succesfull!", 3)
                    Else
                        DirCopy($SplitSource[1], $DestinationPath, $Overwrite)
                        FileCopy($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        MsgBox(262144, "Success", "File-Folder copy operation was succesfull!", 3)
                    EndIf
                Else
                    If $FilesOnly = 1 Then
                        For $Countpaths = 1 To $SplitSource[0]
                            FileCopy($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        Next
                        MsgBox(262144, "Success", "File copy operation was succesfull!", 3)
                    Else
                        For $Countpaths = 1 To $SplitSource[0]
                            DirCopy($SplitSource[$Countpaths], $DestinationPath, $Overwrite)
                            FileCopy($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                            MsgBox(262144, "Success", "File-Folder copy operation was succesfull!", 3)
                        Next
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
EndFunc   ;==>CopyFiles

Func Move()
    Local $MoveError = 0
    $SourcePath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "SourcePath", "NotFound")
    If $SourcePath = "" Then
        SourcePathEmpty()
    Else
        FileChangeDir($SourcePath)
        $CheckSplit = StringSplit($SourcePath, ",")
        If @error = 1 Then
            $Path = FileExists($CheckSplit[1])
            If $Path = 0 Then
                SourcePathInvalid1()
            Else
                MoveFiles()
            EndIf
        Else
            For $CheckPathCount = 1 To $CheckSplit[0]
                $Path = FileExists($CheckSplit[$CheckPathCount])
                If $Path = 0 Then
                    SourcePathInvalid2($CheckPathCount)
                    $MoveError = $MoveError + 1
                EndIf
            Next
            If $MoveError = 0 Then
                MoveFiles()
            EndIf
        EndIf
    EndIf
EndFunc   ;==>Move

Func MoveFiles()
    $Ext = IniRead(@ScriptDir & "\Settings.ini", "Options", "Extension", "*.*")
    $Search1 = FileFindFirstFile("*.*")
    If $Search1 = -1 Then
        FileClose($Search1)
        FolderEmpty()
    Else
        FileClose($Search1)
        $Search2 = FileFindFirstFile($Ext)
        If $Search2 = -1 Then
            FileClose($Search2)
            NoExt()
        Else
            FileClose($Search2)
            $DestinationPath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "DestinationPath", "NotFound")
            If $DestinationPath = "" Then
                DestinationPathEmpty()
            Else
                $Overwrite = IniRead(@ScriptDir & "\Settings.ini", "Options", "Overwrite", "NotFound")
                $FilesOnly = IniRead(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", "NotFound")
                $SplitSource = StringSplit($SourcePath, ",")
                If @error = 1 Then
                    If $FilesOnly = 1 Then
                        FileMove($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        MsgBox(262144, "Success", "File move operation was succesfull!", 3)
                    Else
                        DirMove($SplitSource[1], $DestinationPath, $Overwrite)
                        FileMove($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        MsgBox(262144, "Success", "File-Folder move operation was succesfull!", 3)
                    EndIf
                Else
                    If $FilesOnly = 1 Then
                        For $Countpaths = 1 To $SplitSource[0]
                            FileMove($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                        Next
                        MsgBox(262144, "Success", "File move operation was succesfull!", 3)
                    Else
                        For $Countpaths = 1 To $SplitSource[0]
                            DirMove($SplitSource[$Countpaths], $DestinationPath, $Overwrite)
                            FileMove($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                            MsgBox(262144, "Success", "File-Folder move operation was succesfull!", 3)
                        Next
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
EndFunc   ;==>MoveFiles

Func SourcePathEmpty()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (Source Path)", "Source path is empty")
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>SourcePathEmpty

Func DestinationPathEmpty()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (Destination Path)", "Destination path is empty")
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>DestinationPathEmpty

Func SourcePathInvalid1()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (Source path)", "Source path does not exist:" & $CheckSplit[1])
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>SourcePathInvalid1

Func SourcePathInvalid2($ErrorPath)
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (Source path)", "Source path does not exist: " & $CheckSplit[$ErrorPath])
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>SourcePathInvalid2

Func FolderEmpty()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (No files/folders)", "No files/folders found in the source path")
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>FolderEmpty

Func NoExt()
    GUISetState(@SW_DISABLE, $MainGUI)
    MsgBox(262160, "Error (No such files)", "No files with that extension found in the source path")
    GUISetState(@SW_ENABLE, $MainGUI)
EndFunc   ;==>NoExt

Func Options()
    GUISetState(@SW_DISABLE, $MainGUI)
    $SourcePath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "SourcePath", "NotFound")
    $DestinationPath = IniRead(@ScriptDir & "\Settings.ini", "Paths", "DestinationPath", "NotFound")
    $OverwriteCheck = IniRead(@ScriptDir & "\Settings.ini", "Options", "Overwrite", "NotFound")
    $FilesOnlyCheck = IniRead(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", "NotFound")
    $AlwaysOnTop = IniRead(@ScriptDir & "\Settings.ini", "Options", "AlwaysOnTop", "NotFound")
    $Ext = IniRead(@ScriptDir & "\Settings.ini", "Options", "Extension", "*.*")
    $SecGUI = GUICreate("Options", 500, 180, -175, Default, 0, BitOR($WS_EX_MDICHILD, $WS_EX_ACCEPTFILES), $MainGUI)
    GUICtrlCreateLabel("Source:", 5, 7, 45, 20)
    $SourceInput = GUICtrlCreateInput($SourcePath, 80, 5, 348, 20, $ES_AUTOHSCROLL)
    GUICtrlSetState($SourceInput, $GUI_DROPACCEPTED)
    GUICtrlCreateLabel("Destination:", 5, 32, 70, 20)
    $DestinationInput = GUICtrlCreateInput($DestinationPath, 80, 30, 348, 20, $ES_AUTOHSCROLL)
    GUICtrlSetState($DestinationInput, $GUI_DROPACCEPTED)
    $Clear = GUICtrlCreateButton("Clear", 434, 5, 55, 20)
    GUICtrlSetOnEvent($Clear, "ClearSourceInput")
    $Browse = GUICtrlCreateButton("Browse", 434, 30, 55, 20)
    GUICtrlSetOnEvent($Browse, "FolderBrowse")
    $Save = GUICtrlCreateButton("Save", 180, 120, 70, 25, $BS_DEFPUSHBUTTON)
    GUICtrlSetOnEvent($Save, "Save")
    $Cancel = GUICtrlCreateButton("Cancel", 256, 120, 70, 25)
    GUICtrlSetOnEvent($Cancel, "CloseOptions")
    $ExtLabel = GUICtrlCreateLabel("Extention", 197, 65, 55, 20)
    $ExtInput = GUICtrlCreateInput($Ext, 195, 80, 50, 20, $ES_AUTOHSCROLL)
    $Check1 = GUICtrlCreateCheckbox("Overwrite", 250, 70, 65, 20)
    If $OverwriteCheck = 1 Then
        GUICtrlSetState($Check1, $GUI_CHECKED)
    Else
        GUICtrlSetState($Check1, $GUI_UNCHECKED)
    EndIf
    $Check2 = GUICtrlCreateCheckbox("Always on top", 250, 90, 85, 20)
    If $AlwaysOnTop = 1 Then
        GUICtrlSetState($Check2, $GUI_CHECKED)
    Else
        GUICtrlSetState($Check2, $GUI_UNCHECKED)
    EndIf
    GUICtrlCreateGroup("Copy/Move", 80, 55, 110, 60)
    $Radio1 = GUICtrlCreateRadio("Files only", 85, 70, 65, 20)
    $Radio2 = GUICtrlCreateRadio("Files and folders", 85, 90, 96, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlSetOnEvent($Radio1, "ExtOn")
    GUICtrlSetOnEvent($Radio2, "ExtOff")
    If $FilesOnlyCheck = 1 Then
        GUICtrlSetState($Radio1, $GUI_CHECKED)
    Else
        GUICtrlSetState($Radio2, $GUI_CHECKED)
        GUICtrlSetState($ExtInput, $GUI_DISABLE)
        GUICtrlSetState($ExtLabel, $GUI_DISABLE)
    EndIf
    GUISetState(@SW_SHOW)
    DropGUI()
EndFunc   ;==>Options

Func DropGUI()
    $DropGUI = GUICreate("Drop Zone", 80, 80,400,60, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_ACCEPTFILES, $WS_EX_TRANSPARENT, $WS_EX_CLIENTEDGE), $SecGUI)
    $DropLabel = GUICtrlCreateLabel("Drop Folders", 15, 40, 70, 20)
    $Graphic = GUICtrlCreateGraphic (0,0,80,80)
    GUICtrlSetState($Graphic, $GUI_DROPACCEPTED)
    GUISetOnEvent($GUI_EVENT_DROPPED, "GetText")
    GUICtrlSetState($DropLabel, $GUI_DISABLE)
    GUISetState(@SW_SHOW)
EndFunc

Func GetText()
    $Focused =  GetFocus($SecGUI)
    If $Focused = 8 OR $Focused = 10 Then
        $InputData = GUICtrlRead($Focused)
        SourceDropped()
    EndIf
EndFunc   ;==>GetText

Func GetFocus($GuiInput)
    Local $InputID = ControlGetHandle($GuiInput, "", ControlGetFocus($GuiInput))
    Local $Result = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $InputID)
    Return $Result[0]
EndFunc

Func SourceDropped()
    If StringInStr(FileGetAttrib(@GUI_DragFile), "D") Then
        If $InputData = "" Then
            GUICtrlSetData($Focused, @GUI_DragFile)
        Else
            GUICtrlSetData($Focused, "," & @GUI_DragFile, ".")
        EndIf
    EndIf
EndFunc   ;==>SourceDropped

Func ClearSourceInput()
    GUICtrlSetData($SourceInput, "")
EndFunc   ;==>ClearSourceInput

Func FolderBrowse()
    $SelectedFolder = FileSelectFolder("Choose a folder.", "", 7, "", $SecGUI)
    GUICtrlSetData($DestinationInput, $SelectedFolder, "")
EndFunc   ;==>FolderBrowse

Func CloseOptions()
    GUISetState(@SW_ENABLE, $MainGUI)
    GUIDelete(@GUI_WinHandle)
EndFunc   ;==>CloseOptions

Func ExtOn()
    GUICtrlSetState($ExtInput, $GUI_ENABLE)
    GUICtrlSetState($ExtLabel, $GUI_ENABLE)
EndFunc   ;==>ExtOn

Func ExtOff()
    GUICtrlSetState($ExtInput, $GUI_DISABLE)
    GUICtrlSetState($ExtLabel, $GUI_DISABLE)
EndFunc   ;==>ExtOff

Func Save()
    $SourceRead = GUICtrlRead($SourceInput)
    IniWrite(@ScriptDir & "\Settings.ini", "Paths", "SourcePath", $SourceRead)
    $DestinationRead = GUICtrlRead($DestinationInput)
    IniWrite(@ScriptDir & "\Settings.ini", "Paths", "DestinationPath", $DestinationRead)
    $ExtensionRead = GUICtrlRead($ExtInput)
    If $ExtensionRead = "" Then
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "Extension", "*.*")
    Else
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "Extension", $ExtensionRead)
    EndIf
    $CheckRead1 = GUICtrlRead($Check1)
    If $CheckRead1 = $GUI_UNCHECKED Then
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "Overwrite", 0)
    Else
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "Overwrite", 1)
    EndIf
    $CheckRead2 = GUICtrlRead($Check2)
    If $CheckRead2 = $GUI_UNCHECKED Then
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "AlwaysOnTop", 0)
        WinSetOnTop($MainGUI, "", 0)
    Else
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "AlwaysOnTop", 1)
        WinSetOnTop($MainGUI, "", 1)
    EndIf
    $RadioRead = GUICtrlRead($Radio1)
    If $RadioRead = $GUI_UNCHECKED Then
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", 0)
    Else
        IniWrite(@ScriptDir & "\Settings.ini", "Options", "FilesOnly", 1)
    EndIf
    GUISetState(@SW_ENABLE, $MainGUI)
    GUIDelete(@GUI_WinHandle)
EndFunc   ;==>Save

Func Quit()
    GUIDelete($MainGUI)
    Exit
EndFunc   ;==>Quit
Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

this doesnt work

$SourcePath= @DesktopDir & "\dir"
 $DestinationPath = @DesktopDir & "\dir1"
 
 CopyFiles()
 
 Func CopyFiles()
     $Ext = "*.*"
     $Search1 = FileFindFirstFile("*.*")
     If $Search1 = -1 Then
         FileClose($Search1)
         FolderEmpty()
     Else
         FileClose($Search1)
         $Search2 = FileFindFirstFile($Ext)
         If $Search2 = -1 Then
             FileClose($Search2)
             NoExt()
         Else
             FileClose($Search2)
             If $DestinationPath = "" Then
                 DestinationPathEmpty()
             Else
                 $Overwrite = "1"
                 $FilesOnly = "0"
                 $SplitSource = StringSplit($SourcePath, ",")
                 If @error = 1 Then
                     If $FilesOnly = 1 Then
                         FileCopy($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                         MsgBox(262144, "Success", "File copy operation was succesfull!", 3)
                     Else
                         DirCopy($SplitSource[1], $DestinationPath, $Overwrite)
                         FileCopy($SplitSource[1] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                         MsgBox(262144, "Success", "File-Folder copy operation was succesfull!", 3)
                     EndIf
                 Else
                     If $FilesOnly = 1 Then
                         For $Countpaths = 1 To $SplitSource[0]
                             FileCopy($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                         Next
                         MsgBox(262144, "Success", "File copy operation was succesfull!", 3)
                     Else
                         For $Countpaths = 1 To $SplitSource[0]
                             DirCopy($SplitSource[$Countpaths], $DestinationPath, $Overwrite)
                             FileCopy($SplitSource[$Countpaths] & "\" & $Ext, $DestinationPath & "\" & $Ext, 8 + $Overwrite)
                             MsgBox(262144, "Success", "File-Folder copy operation was succesfull!", 3)
                         Next
                     EndIf
                 EndIf
             EndIf
         EndIf
     EndIf
 EndFunc ;==>CopyFiles

but if you change

@DesktopDir & "\dir

to

C:\Users\XXX\Desktop\dir

it works!!

Edited by bluerein
Link to comment
Share on other sites

  • Moderators

Well, the reason they aren't working, is because they are two completely different paths.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I think @DesktopDir is X:\Documents and Setting\User\Desktop\ at least on XP, maybe Vista is different...

Also If you use my code, maybe you want the ini also, in the dir you have it also keep a Settings.ini which contains:

The comments are just to help you out :mellow:

;Set the source and destination paths.For many sources separate with a coma (,).

;The program will copy/move the source(s), or all the contents of the source(s) into the destination

;If you use C:\Windows as the source, a folder named Windows will be created and all it's contents

;will be copied/moved, if you use C:\Windows\ no folder will be created and only the contents will

; be copied/moved.

[Paths]

SourcePath=

DestinationPath=

;1 for Overwrite, 0 do not Overwrite

;1 for Files Only, 0 for folders also

;1 for always on top, 0 for off

[Options]

Overwrite=1

FilesOnly=1

AlwaysOnTop=1

Extension=*.*

Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

I've had the same problem on a couple of scripts I have wrote. It seems that @DesktopDir, @DocumentsDir, etc... are wrote to use the XP paths of

c:\documents and settings\User Name\Desktop and not the Vista path of c:\users\user name\desktop. For the scripts that I needed to run on Vista I have typed out the full path to the file/folder I need to copy. If you are looking to use this on multiple operating systems you might want to run some sort of check at the beginning to see what OS the machine is running. If it is XP you can use @desktopdir and if it is Vista use the complete path.

Link to comment
Share on other sites

I've had the same problem on a couple of scripts I have wrote. It seems that @DesktopDir, @DocumentsDir, etc... are wrote to use the XP paths of

c:\documents and settings\User Name\Desktop and not the Vista path of c:\users\user name\desktop. For the scripts that I needed to run on Vista I have typed out the full path to the file/folder I need to copy. If you are looking to use this on multiple operating systems you might want to run some sort of check at the beginning to see what OS the machine is running. If it is XP you can use @desktopdir and if it is Vista use the complete path.

Thanks for the reply!

Looks like thats the only option then..

thanks

Link to comment
Share on other sites

  • Moderators

I think what's weird is in Vista I get the same values for both and you don't... but look at the article below this code:

ConsoleWrite(_DesktopDir_Vista() & @CRLF & @DesktopDir & @CRLF)

Func _DesktopDir_Vista()
    Local $s_desktop = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Desktop")
    Local $a_sre = StringRegExp($s_desktop, "%(.*?)%(.*?)\z", 1)
    If @error Then Return SetError(1, 0, "")
    Return EnvGet($a_sre[0]) & $a_sre[1]
EndFunc

Might want to read this though: http://support.microsoft.com/kb/943805

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...