Jump to content

cmd to Autoit #3


 Share

Recommended Posts

Good day,

Well...via the assistance of somdcomputerguy and, for his most excellent offerings, ioa747, I have finally completed the "port".

However, there are apparently small "glitches" with the .au3 script versus the .cmd script. I feel that I have gone over these scripts side-by-side "with a fine toothed comb".
• What appears to be the primary issue here is that the folder icons for Drive G are not being updated with the .au3 script.
• I use disk-imaging to restore the system prior to the execution of the script, and the .cmd script works...but, for whatever reason, the .au3 script does not.

I am providing both scripts for someone to "glean" over sometime...and if possible...to offer reasons as to why the /au3 script appears not to work as expected.

relocate_user_folders.au3relocate_user_folders.cmd

Any assistance in this matter would be greatly appreciated!

PS: Peruse the following image...

All.png.8bbdd5fff33f05fdf19ccecb39deb2de.png

Edited by mr-es335
Link to comment
Share on other sites

6 hours ago, mr-es335 said:

What appears to be the primary issue here is that the folder icons for Drive G are not being updated with the .au3 script

with a quick overview i saw:
    Func _CopyIniFilesE()
    Func _CopyIniFilesF()

but nowhere
    Func _CopyIniFilesG()

 

Something else I noticed is:
that you have the folders in a different location ("D:\Install\System_Config\Folders\Source_Data_E")
and in a different location the desktop.ini files ("D:\Install\System_Config\ini_files\E\")

Why?
The folders from the location ("D:\Install\System_Config\Folders\Source_Data_E")
do not contain the desktop.ini files?

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

ioa747,

I will endeavor to answer your queries in turn:

Q1: What appears to be the primary issue here is that the folder icons for Drive G are not being updated with the .au3 script?
R1: In the original script [Link], there is a section entitled, "rem Copy (desktop.ini) files (folder icon fix):"
1) As can be observed in that original script, he was "relocating" the selected folders from [C:\] to [D:\]
• set oldPath=C:\Users\%user%\ - set newPath=D:\%user%\
• What is somewhat surprising here is that he "missed" the User's "Desktop" folder!
• Though it does not indicate what the specifics of the desktop.ini file is involved, I could "assume" that the writer was employing the original desktop.ini files.
• As the specified folders are indeed, what I refer to as "user system folders" - as a result of the "Location" tab, such folders have their own desktop.ini files.
https://social.technet.microsoft.com/Forums/en-US/7f1b5172-1748-44ab-af89-cdcb0ec60a7c/local-folder-redirection-batch-file-command-prompt-cmd-script

Q2: ...that you have the folders in a different location ("D:\Install\System_Config\Folders\Source_Data_E") and in a different location the desktop.ini files ("D:\Install\System_Config\ini_files\E\")
R2: Firstly, I was attempting to be as "faithful to the original script" - inasmuch as I was able to...for my own personal need and requirements anyhow.
• See: "rem Setting variables to use when applying folder redirection in registry." and "rem Copy (desktop.ini) files (folder icon fix):"
• Secondly, as I was not employing the original icons as those in the original desktop.ini files, I thought it prudent to keep such data in their own locations [...which I see now from your comments...is not necessary]. Thanks!

Other points to note...
In my script, the _UpdateFoldersIcons() functions - I do believe in a way, negates the need for the separate .ini files, as I am attempting to "globally" update the "user system" folder icons for any-and-all such folders.
• See "How to Change the Windows 7 Default Folder Icon": [Link]
https://www.sevenforums.com/tutorials/23825-folder-icon-change-windows-7-default-folder-icon.html
 
Following is the text from that function:
• Local $sRegistryPath1 = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\DefaultIcon"
•Local $IconValue3 = "D:\Install\System_Config\Icons\folder.ico"
•RegWrite($sRegistryPath1, "(3)", "REG_SZ", $IconValue3)
• Note: After deploying this function, any-and-all Explorer folder icons should adopt the updated folder.ico data file.
• This should negate the need for the "rem Copy (desktop.ini) files (folder icon fix):" section as I was not requiring the need for "different icons" for each of the specified folders.

An important note...
What IS interesting,. is that my original cmd script DOES invoke that update, whilst the .au3 script does not! Interesting!

1) My original cmd script:

:: Update folder icons...
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v "3" /t REG_SZ /d D:\Install\System_Config\Icons\folder.ico /f
echo Updating System folder icons completed.

2) The .au3 script

;Update folder icons...
Local $sRegistryPath3 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons"
;------------------
Local $IconValue3 = "D:\Install\System_Config\Icons\folder.ico"
;------------------
RegWrite($sRegistryPath1, "(3)", "REG_SZ", $IconValue3)

IMPORTANT UPDATE!
I discovered why the .au3 script was NOT globally updating the Explorer folder icons!
• Compare the following:
a) RegWrite($sRegistryPath1, "(3)", "REG_SZ", $IconValue3)
b) RegWrite($sRegistryPath1, "3", "REG_SZ", $IconValue3)

Observations
1) As to why I added the "()'s" I have no idea? However, when removed...all was well!
2) The above does clearly demonstrate however, that the functions "_CopyIniFilesE()" and "_CopyIniFilesF()" are no longer required!

Before.png.d280298f64c28abc76974112779ff1da.png

After.png.dbfc008a3b4e1b33e1ec623000746a61.png

In closing...
I do hope that the above explains "all the goings on", and that such does make sense? I also wish to sincerely thank you ios747, for your wisdom and your insights into this matter. I do appreciate such very much!

Edited by mr-es335
Link to comment
Share on other sites

Good day,

With regards to the previous post, I have updated the script as follows:

;------------------------------------------------
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
;------------------------------------------------
;relocate_user_folders
;Updated script by ioa747...with gratitude!
;Last updated: 7:31 AM 12/10/2023
;Last confirmed: 7:43 AM 12/10/2023
;------------------------------------------------
_CopyUserFolders()
_RegFolderRedirection()
_CleanupOldFolders()
_UpdateFoldersIcons()
_RestartComputer()
;------------------------------------------------
Func _CopyUserFolders()
    Local $sSrcDataE = "D:\Install\System_Config\Folders\Source_Data_E"
    Local $sSrcDataF = "D:\Install\System_Config\Folders\Source_Data_F"
    Local $sSrcDataG = "D:\Install\System_Config\Folders\Source_Data_G"
    Local $sDstDataE = "E:\"
    Local $sDstDataF = "F:\"
    Local $sDstDataG = "G:\"
    ;------------------
    SplashTextOn("Notice!", "Copying User System Folders...", 350, 50, -1, -1)
    Sleep(2000)
    ;------------------
    DirCopy($sSrcDataE, $sDstDataE, $FC_OVERWRITE)
    DirCopy($sSrcDataF, $sDstDataF, $FC_OVERWRITE)
    DirCopy($sSrcDataG, $sDstDataG, $FC_OVERWRITE)
    ;------------------
    SplashTextOn("Notice!", "Copying User System Folders completed...", 350, 50, -1, -1)
    Sleep(3000)
EndFunc   ;==>_CopyUserFolders
;------------------------------------------------
Func _RegFolderRedirection()
    ;Configuring the required variables for use when applying folder redirection in the registry.
    Local $sNewDesktop = "E:\Desktop"
    Local $sNewDocuments = "E:\Text"
    Local $sNewDownloads = "E:\Downloads"
    Local $sNewMusic = "F:\Audio"
    Local $sNewPictures = "E:\Images"
    Local $sNewVideos = "E:\Video"
    ;------------------
    Local $sRegistryPath1 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
    Local $sRegistryPath2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
    ;------------------
    SplashTextOn("Notice!", "Begin folder redirection in the Registry...", 350, 50, -1, -1)
    Sleep(2000)
    ;------------------
    ;Updating the specified registry keys.
    RegWrite($sRegistryPath1, "Desktop", "REG_SZ", $sNewDesktop)
    RegWrite($sRegistryPath1, "Personal", "REG_SZ", $sNewDocuments)
    RegWrite($sRegistryPath1, "Downloads", "REG_SZ", $sNewDownloads)
    RegWrite($sRegistryPath1, "My Music", "REG_SZ", $sNewMusic)
    RegWrite($sRegistryPath1, "My Pictures", "REG_SZ", $sNewPictures)
    RegWrite($sRegistryPath1, "My Video", "REG_SZ", $sNewVideos)
    ;------------------
    RegWrite($sRegistryPath2, "Desktop", "REG_EXPAND_SZ", $sNewDesktop)
    RegWrite($sRegistryPath2, "Personal", "REG_EXPAND_SZ", $sNewDocuments)
    RegWrite($sRegistryPath2, "Downloads", "REG_EXPAND_SZ", $sNewDownloads)
    RegWrite($sRegistryPath2, "My Music", "REG_EXPAND_SZ", $sNewMusic)
    RegWrite($sRegistryPath2, "My Pictures", "REG_EXPAND_SZ", $sNewPictures)
    RegWrite($sRegistryPath2, "My Video", "REG_EXPAND_SZ", $sNewVideos)
    ;------------------
    RegWrite($sRegistryPath2, "{754AC886-DF64-4CBA-86B5-F7FBF4FBCEF5}", "REG_EXPAND_SZ", $sNewDesktop)
    RegWrite($sRegistryPath2, "{F42EE2D3-909F-4907-8871-4C22FC0BF756}", "REG_EXPAND_SZ", $sNewDocuments)
    RegWrite($sRegistryPath2, "{374DE290-123F-4565-9164-39C4925E467B}", "REG_EXPAND_SZ", $sNewDownloads)
    RegWrite($sRegistryPath2, "{A0C69A99-21C8-4671-8703-7934162FCF1D}", "REG_EXPAND_SZ", $sNewMusic)
    RegWrite($sRegistryPath2, "{0DDD015D-B06C-45D5-8C4C-F59713854639}", "REG_EXPAND_SZ", $sNewPictures)
    RegWrite($sRegistryPath2, "{35286A68-3C57-41A1-BBB1-0EAE73D76C95}", "REG_EXPAND_SZ", $sNewVideos)
    ;------------------
    SplashTextOn("Notice!", "Folder redirection in the Registry completed...", 350, 50, -1, -1)
    Sleep(3000)
EndFunc   ;==>_RegFolderRedirection
;------------------------------------------------
Func _CleanupOldFolders()
    ;Clean old user folders.
    ;Updated script by ioa747...with gratitude!
    Local $sOldPath = "C:\Users\RML_User"
    Local $aFolders = "Desktop, Documents, Downloads, Favorites, Music, Pictures, Videos"
    ;------------------
    $aFolders = StringSplit($aFolders, ", ", 1)
    ;------------------
    SplashTextOn("Notice!", "Removing existing User system folders...", 350, 50, -1, -1)
    Sleep(2000)
    ;------------------
    For $i = 1 To $aFolders[0]
        DirRemove($sOldPath & "\" & $aFolders[$i], $DIR_REMOVE)
    Next
    ;------------------
    SplashTextOn("Notice!", "Removing existing User system folders completed...", 450, 50, -1, -1)
    Sleep(3000)
EndFunc   ;==>_CleanupOldFolders
;------------------------------------------------
Func _UpdateFoldersIcons()
    ;Update folder icons...
    Local $sRegistryPath1 = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\DefaultIcon"
    Local $sRegistryPath2 = "HKEY_CLASSES_ROOT\cmdfile\DefaultIcon"
    Local $sRegistryPath3 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons"
    ;------------------
    Local $IconValue1 = "D:\Install\System_Config\Icons\computer.ico"
    Local $IconValue2 = "D:\Install\System_Config\Icons\command.ico"
    Local $IconValue3 = "D:\Install\System_Config\Icons\folder.ico"
    ;------------------
    SplashTextOn("Notice!", "Updating folder icons...", 350, 50, -1, -1)
    Sleep(2000)
    ;------------------
    RegWrite($sRegistryPath1, "(Default)", "REG_SZ", $IconValue1)
    RegWrite($sRegistryPath2, "(Default)", "REG_EXPAND_SZ", $IconValue2)
    RegWrite($sRegistryPath3, "3", "REG_SZ", $IconValue3)
    RegWrite($sRegistryPath3, "4", "REG_SZ", $IconValue3)
    ;------------------
    SplashTextOn("Notice!", "Updating folder icons completed...", 350, 50, -1, -1)
    Sleep(3000)
EndFunc   ;==>_UpdateFoldersIcons
Func _RestartComputer()
    Shutdown(2)
EndFunc   ;==>_RestartComputer
;------------------------------------------------

Please keep in mind that this script DOES employ a single folder icon for ALL Explore folders!!
• I have attached that icon - as well as the compute.ico and command.ico files to this posting for those that might be interested.

folder.icocomputer.icocmd.ico

I hope this information will be of some practicable use?

Edited by mr-es335
Link to comment
Share on other sites

Good day,

A tiny "glitch"...rectified...[Repeat after me..."Read the Manual!"...repeat as often as is necessary!!]

What I HAD...

;------------------
RegWrite($sRegistryPath1, "(Default)", "REG_SZ", $IconValue1)
RegWrite($sRegistryPath2, "(Default)", "REG_EXPAND_SZ", $IconValue2)
;------------------

...and what I UPDATED to...

;------------------
;To access the (Default) value use "" (an empty string) for the valuename.
RegWrite($sRegistryPath1, "", "REG_SZ", $IconValue1) ;(Default) value
RegWrite($sRegistryPath2, "", "REG_EXPAND_SZ", $IconValue2) ;(Default) value
;------------------

...now...resolved...!! "Next topic, please!

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...