Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
vio69 Profile
Femeie
25 ani
Botosani
cauta Barbat
25 - 50 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [VBSCRIPT] Script to batch edit desktop.ini for multiple folders Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Source:

Put this in a vbs file and run in the cmd with the argument being the folder the folders are in, eg: you should run "EditDesktopIni e:\movies" in the cmd window


' Run with cmd: EditDesktopIni E:\ZG

EditDesktopIni(Wscript.Arguments(0))

Sub EditDesktopIni(foldpath)
    Dim fso, inifile, icondata, file, fold, subfold, item, subfoldpath
    Const ForReading = 1, ForWriting = 2
    Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fold = fso.GetFolder(foldpath)
    Set subfold = fold.SubFolders
    For Each item In subfold
        inifile = foldpath + "\" + item.Name + "\desktop.ini"
        subfoldpath = foldpath & "\" & item.name
        If (fso.FileExists(inifile)) Then ' if desktop.ini exists, delete it
            fso.DeleteFile inifile, True
        End If
        Set file = fso.OpenTextFile(inifile, ForWriting, True, TristateUseDefault)

        file.WriteLine "[.ShellClassInfo]"
        file.WriteLine "IconResource=" & subfoldpath & ".ico" & ",0"
        file.WriteLine "[ViewState]"
        file.WriteLine "Mode="
        file.WriteLine "Vid="
        file.WriteLine "FolderType=Generic"
        file.WriteLine ""

        fso.GetFile(inifile).Attributes = 6
        item.Attributes = 0
        item.Attributes = 4 ' set the folder to system to refresh the icon
    Next
End Sub


_______________________________________


pus acum 4 ani
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
'
A slightly modified version by me in which you insert Folder path and ICO index from a DLL specified in the code below:

Dim fso, inifile, icoNum, file, item, foldpath, fold

' this is the path of the folder you want to change icon
    foldpath = inputbox("Please enter complete folder path", "String")

' this is the index number of the icon in D:\TOOLBAR-DLL\IconLibrary.dll
    icoNum = inputbox("Insert icon index from DLL file", "String")
   
Const ForReading = 1, ForWriting = 2
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Set fso = CreateObject("Scripting.FileSystemObject")
Set fold = fso.GetFolder(foldpath)
    inifile = foldpath + "\" + "\desktop.ini"

    If (fso.FileExists(inifile)) Then ' if desktop.ini exists, delete it
        fso.DeleteFile inifile, True
    End If
       
Set file = fso.OpenTextFile(inifile, ForWriting, True, TristateUseDefault)

    file.WriteLine "[.ShellClassInfo]"
    file.WriteLine "IconResource=D:\TOOLBAR-DLL\IconLibrary.dll," & icoNum
    file.WriteLine "[ViewState]"
    file.WriteLine "Mode="
    file.WriteLine "Vid="
    file.WriteLine "FolderType=Generic"
    file.WriteLine ""

    fso.GetFile(inifile).Attributes = 6
    fold.Attributes = 0
    fold.Attributes = 4 ' set the folder to system to refresh the icon
   
' refresh icons - still doesn't work instantly unfortunately
Dim objWshShell
Set objWshShell = WScript.CreateObject("WScript.Shell")

objWshShell.Run "ie4uinit.exe -cleariconcache"
WScript.Sleep(1000)
objWshShell.Run "ie4uinit.exe -show"
WScript.Sleep(1000)


_______________________________________


pus acum 4 ani
   
Pagini: 1  

Mergi la