INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

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

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

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

(OP)
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 ?



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

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
'******************************************************************** 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close