Test.JS- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var msg = '';
-
- for( var i=0; i<WSH.Arguments.length; i++ ){
- var fd = WSH.Arguments(i);
- if( fso.FolderExists(fd) ){
- if( fso.FileExists(fd + '\\desktop.ini') ) fso.DeleteFile(fd + '\\desktop.ini', true);
- createFile(fd);
- } else {
- msg += fd + ' is not FOLDER\n';
- }
- }
-
- function createFile(fd){
- var icon = '';
- var e = new Enumerator(fso.GetFolder(fd).Files);
- for( ; !e.atEnd(); e.moveNext() ){
- if( /\.ico$/i.test(e.item().Name) ){
- var icon = e.item().Name;
- break;
- }
- }
- if( icon != '' ){
- var str = '[.ShellClassInfo]\r\nIconResource=' + icon;
- var objFile = fso.OpenTextFile(fd + '\\desktop.ini', 2, true);
- objFile.WriteLine(str);
- objFile.Close();
- var sh = new ActiveXObject('WSCript.Shell');
- sh.Run('cmd /c attrib +s +h "' + fd + '\\desktop.ini" & attrib +s +h "' + fd + '\\' + icon + '" & attrib +s +r /d /s "' + fd + '"');
- } else {
- msg += fd + ' ICON not FOUND\n';
- }
- }
-
- WSH.Echo(msg == '' ? 'Done' : msg)
复制代码
|