Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i show the change icon dialog box, with a vbscript or a command line ?

Status
Not open for further replies.

hackoo

Programmer
Jan 31, 2003
28
TN
How can i show the change icon dialog box, with a vbscript or a command line and use informations throw it in my vbscript in order to let the user choose what icon he wants to set from the change icon dialog box ?

gPPPr.jpg


Here is my vbscript that i created and i tested on my windows 10 and it worked to create a folder on the desktop and change its icon to Padlock icon.
So my question : is there any method to show this dialog box to let the user set what he wants as icon and use it by vbscript ?

Code:
Option Explicit
Dim Ws,Icon,strText,DesktopFolder,strFolder
Set Ws = CreateObject("wscript.Shell")
DesktopFolder = ws.SpecialFolders("Desktop")
strFolder = DesktopFolder & "\Hackoo Folder Icon Changer"
Icon = "%systemroot%\system32\shell32.dll,-48"
strText = "[.ShellClassInfo]" & vbCrLf &_
"IconResource="& Icon & vbCrLf &_
"IconFile=%systemroot%\system32\shell32.dll"
'Create a folder on our desktop
Call SmartCreateFolder(strFolder)
'Transform our folder to a system folder
Call Execute("attrib +s " & DblQuote(strFolder))
Call Write_INI_File(strFolder,strText)
Ws.Run "ie4uinit.exe -ClearIconCache"
Ws.Run "ie4uinit.exe -show"
'********************************************************************
Sub SmartCreateFolder(strFolder)
    Dim oFSO:Set oFSO = CreateObject("Scripting.FileSystemObject")
    If oFSO.FolderExists(strFolder) Then
        Exit Sub
    Else
        SmartCreateFolder(oFSO.GetParentFolderName(strFolder))
    End If
    oFSO.CreateFolder(strFolder)
    Set oFSO = Nothing    
End Sub
'********************************************************************
Function Execute(StrCmd)
    Dim ws,MyCmd,Resultat
    Set ws = CreateObject("wscript.Shell")
        MyCmd = "CMD /C " & StrCmd & ""
        Resultat = ws.run(MyCmd,0,True)
        If Resultat <> 0 Then
            MsgBox "Une erreur inconnue est survenue !",16,_
			"Une erreur inconnue est survenue !"
        End If
    Execute = Resultat
End Function
'********************************************************************
Sub Write_INI_File(PathFolder,strText)
Dim fs,ts,DesktopINI
Const ForWriting = 2
    DesktopINI = PathFolder & "\Desktop.ini"
    Set fs = CreateObject("Scripting.FileSystemObject")
    if fs.FileExists(DesktopINI) Then 
    	Call Execute("Attrib -R -H -S "& DblQuote(DesktopINI))
        fs.DeleteFile DesktopINI
    end If
    Set ts = fs.OpenTextFile(DesktopINI,ForWriting,True)
    ts.WriteLine strText
    ts.Close
'Transform the file Desktop.ini to a hidden and system file
	Call Execute("Attrib +R +H +S "& DblQuote(DesktopINI))
End Sub
'********************************************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'********************************************************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top