Achilles Posted May 3, 2010 Share Posted May 3, 2010 Here's what I've tried: $dir = @DesktopDir $name = 'Testing' $ico = @AutoItExe $pass = 6 If FileExists($dir & '\' & $name) then $pass = Msgbox(36, 'Warning', 'The directory you selected already exists. If you continue that directory will be deleted and recreated. Would you like to continue?') EndIf If $pass = 6 then If $name = '' then Msgbox(16, 'Error', 'You must enter a name for the project!') Else $pass = DirCreate($dir & '\' & $name) If $pass = 0 then Msgbox(16, 'Error', 'There was an error created the selected directory.') Else If FileExists($ico) then $file = FileOpen($dir & '\' & $name & '\desktop.ini', 2) FileWriteLine($file, '[.ShellClassInfo]') FileWriteLine($file, 'IconResource=' & $ico & ',0') FileClose($file) $a = FileSetAttrib($dir & '\' & $name & '\desktop.ini', 'HSA') Exit EndIf EndIf EndIf EndIfIt creates the folder fine, it creates the file fine.. but it doesn't actually set the icon.. Any ideas? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
JohnOne Posted May 3, 2010 Share Posted May 3, 2010 I see you are creating a new dir, then you try to open a file inside that same dir. Is there even a file in there ? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
KaFu Posted May 3, 2010 Share Posted May 3, 2010 The trick seems to be this: FileSetAttrib($parent_dir & '\' & $folder_to_create, "+S") $parent_dir = @ScriptDir $folder_to_create = 'Testing' $iconfile_to_use = FileGetShortName(@AutoItExe) $iconfile_to_use_icon_index = 0 If FileExists($parent_dir & '\' & $folder_to_create) Then If MsgBox(4 + 48, 'Warning', 'The directory you selected already exists. If you continue that directory will be deleted and recreated. Would you like to continue?') <> 6 Then Exit FileSetAttrib($parent_dir & '\' & $folder_to_create, "-R") FileDelete($parent_dir & '\' & $folder_to_create) EndIf If Not FileExists($iconfile_to_use) Then MsgBox(16, 'Error', 'The selected icon file does not exist?') Exit EndIf DirCreate($parent_dir & '\' & $folder_to_create) If Not FileExists($parent_dir & '\' & $folder_to_create) Then MsgBox(16, "Error", "Error creating target dir.") EndIf $hFile = FileOpen($parent_dir & '\' & $folder_to_create & '\desktop.ini', 2 + 256) If $hFile = -1 Then MsgBox(16, "Error", "Unable to open file desktop.ini.") Exit EndIf FileWrite($hFile, "[.ShellClassInfo]" & @CRLF & "IconFile=" & $iconfile_to_use & @CRLF & "IconIndex=" & $iconfile_to_use_icon_index & @CRLF) FileClose($hFile) FileSetAttrib($parent_dir & '\' & $folder_to_create, "+S") FileSetAttrib($parent_dir & '\' & $folder_to_create & '\desktop.ini', '+SH') OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Achilles Posted May 3, 2010 Author Share Posted May 3, 2010 The trick seems to be this: FileSetAttrib($parent_dir & '\' & $folder_to_create, "+S") $parent_dir = @ScriptDir $folder_to_create = 'Testing' $iconfile_to_use = FileGetShortName(@AutoItExe) $iconfile_to_use_icon_index = 0 If FileExists($parent_dir & '\' & $folder_to_create) Then If MsgBox(4 + 48, 'Warning', 'The directory you selected already exists. If you continue that directory will be deleted and recreated. Would you like to continue?') <> 6 Then Exit FileSetAttrib($parent_dir & '\' & $folder_to_create, "-R") FileDelete($parent_dir & '\' & $folder_to_create) EndIf If Not FileExists($iconfile_to_use) Then MsgBox(16, 'Error', 'The selected icon file does not exist?') Exit EndIf DirCreate($parent_dir & '\' & $folder_to_create) If Not FileExists($parent_dir & '\' & $folder_to_create) Then MsgBox(16, "Error", "Error creating target dir.") EndIf $hFile = FileOpen($parent_dir & '\' & $folder_to_create & '\desktop.ini', 2 + 256) If $hFile = -1 Then MsgBox(16, "Error", "Unable to open file desktop.ini.") Exit EndIf FileWrite($hFile, "[.ShellClassInfo]" & @CRLF & "IconFile=" & $iconfile_to_use & @CRLF & "IconIndex=" & $iconfile_to_use_icon_index & @CRLF) FileClose($hFile) FileSetAttrib($parent_dir & '\' & $folder_to_create, "+S") FileSetAttrib($parent_dir & '\' & $folder_to_create & '\desktop.ini', '+SH') That did solve it... thanks for your help! My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now