2012-10-31 4 views
0

나는 전에 어떤 vbscript도 사용하지 않았기 때문에 내 질문이 매우 쉬운 지 여부를 알 수 없습니다. 다음은 수행해야 할 단계의 흐름입니다.vbscript를 사용하여 여러 폴더, 바탕 화면 및 시작 메뉴 바로 가기를 삭제하는 방법

존재하는지 확인하고 발견 된 경우 c : \ test1에있는 폴더를 삭제하고 계속하십시오. 발견되지 않으면 계속하십시오. 존재하는지 확인하고 c : \ programfiles \ test2에있는 폴더를 찾아서 삭제 한 후 계속하십시오. 발견되지 않으면 계속하십시오. 바탕 화면 바로 가기 및 시작 메뉴 바로 가기가 있는지 확인하고 발견되면 삭제하십시오. 종료하지 않으면.

나는 다음과 같은 코드로이 개 폴더를 삭제할 수 :

strPath1 = "C:\test1" 
strPath1 = "C:\test1" 
DeleteFolder strPath1 
DeleteFolder strPath1 
Function DeleteFolder(strFolderPath1) 
Dim objFSO, objFolder 
Set objFSO = CreateObject ("Scripting.FileSystemObject") 
If objFSO.FolderExists(strFolderPath) Then 
    objFSO.DeleteFolder strFolderPath, True 
End If 
Set objFSO = Nothing 

하지만 난이 가기 시작 메뉴의 하나는 바탕 화면에 하나, 다른 경로에서이 개 폴더를 삭제 한 스크립트를 실행해야합니다.

내 바탕 화면에 바로 가기를 삭제하려면이 코드를 사용하여 실험 하였다

Dim WSHShell, DesktopPath 
    Set WSHShell = WScript.CreateObject("WScript.Shell") 
    DesktopPath = WSHShell.SpecialFolders("Desktop") 
    on error resume next 
    Icon = DesktopPath & "\sample.txt" 
    Set fs = CreateObject("Scripting.FileSystemObject") 
    Set A = fs.GetFile(Icon) 
    A.Delete 
    WScript.Quit 

그것은 바탕 화면에 txt 파일에 대한 잘 작동하지만 내가 어떻게 시작뿐만 아니라 바탕 화면에서 응용 프로그램에 대한 바로 가기를 삭제합니까 메뉴.

+2

바로 가기는 .lnk이므로 올바른 확장명과 동일한 원칙을 사용하십시오. –

+0

수정을 주셔서 감사합니다 – user1756858

+0

@ 대니얼 : 시작 메뉴에서 제거하려면 .lnk 확장자를 입력해야합니까? 그렇지 않으면 폴더로 간주됩니까? – user1756858

답변

0
strPath1 = "C:\test1" 
strPath2 = "C:\test2" 

DeleteFolder strPath1 
DeleteFolder strPath2 

DeleteShortcut 

'------------------------------------------------------- 
Sub DeleteFolder(strFolderPath) 
    Set fso = CreateObject ("Scripting.FileSystemObject") 
    If fso.FolderExists(strFolderPath) Then 
    fso.DeleteFolder strFolderPath, True 
    End If 
End Sub 

'-------------------------------------------------------  
Sub DeleteShortcut() 
    Set WSHShell = WScript.CreateObject("WScript.Shell") 
    DesktopPath = WSHShell.SpecialFolders("Desktop") 

    shortcutPath = DesktopPath & "\MyShortcut.lnk" 
    Set fso = CreateObject("Scripting.FileSystemObject") 
    If fso.FileExists(shortcutPath) Then 
    Set myFile = fso.GetFile(shortcutPath) 
    myFile.Delete 
    End If 
End Sub 
+0

와우 덕분에 .. – user1756858

관련 문제