2014-09-25 67 views
0

不知道這個問題是否已經問過。 創建了一個批處理文件,其工作正常。但是我需要的是在批處理執行時保持打開的命令提示符。基本上,當我們點擊批處理文件時,只要批處理執行完成,就立即執行「命令提示符」。如果出現任何錯誤,我會發現任何錯誤。所以我想凍結命令提示符。希望我清楚我的問題。批處理文件||如何凍結命令提示符

謝謝。 Arfeen。

回答

1

試着在末端設置PAUSE ???

+0

它工作正常。但是,當我嘗試執行和exe是最終一個批處理文件,然後它不。 – Arfeen 2014-09-25 22:11:45

+0

@Arfeen - 你如何執行批處理文件。你使用'CALL'命令嗎?因爲你需要它..... – npocmaka 2014-09-25 22:19:01

2
rem Pause if command double clicked 
If /i "%cmdcmdline:~0,6%"=="cmd /c" pause 

以上爲最後兩行。如果雙擊,暫停,但如果鍵入則不暫停。

以管理員身份運行

你需要右擊並選擇以管理員身份運行。只有某些程序顯示高程對話框。資源管理器和任務管理器是兩個常見的。該腳本可以自動點擊右鍵。

Lists or runs an explorer verb (right click menu) on a file or folder 

    ShVerb <filename> [verb] 

    Used without a verb it lists the verbs available for the file or folder 

    The program lists most verbs but only ones above the first separator 
    of the menu work when used this way 

    The Properties verb can be used. However the program has to keep running 
    to hold the properties dialog open. It keeps running by displaying 
    a message box. 

腳本

HelpMsg = vbcrlf & " ShVerb" & vbcrlf & vbcrlf & " David Candy 2014" & vbcrlf & vbcrlf & " Lists or runs an explorer verb (right click menu) on a file or folder" & vbcrlf & vbcrlf & " ShVerb <filename> [verb]" & vbcrlf & vbcrlf & " Used without a verb it lists the verbs available for the file or folder" & vbcrlf & vbcrlf 
HelpMsg = HelpMsg & " The program lists most verbs but only ones above the first separator" & vbcrlf & " of the menu work when used this way" & vbcrlf & vbcrlf 
HelpMsg = HelpMsg & " The Properties verb can be used. However the program has to keep running" & vbcrlf & " to hold the properties dialog open. It keeps running by displaying" & vbcrlf & " a message box." 
Set objShell = CreateObject("Shell.Application") 
Set Ag = WScript.Arguments 
set WshShell = WScript.CreateObject("WScript.Shell") 
Set fso = CreateObject("Scripting.FileSystemObject") 

    If Ag.count = 0 then 
     wscript.echo " ShVerb - No file specified" 
     wscript.echo HelpMsg 
     wscript.quit 
    Else If Ag.count = 1 then 
     If LCase(Replace(Ag(0),"-", "/")) = "/h" or Replace(Ag(0),"-", "/") = "/?" then 
      wscript.echo HelpMsg 
      wscript.quit 
     End If 
    ElseIf Ag.count > 2 then 
     wscript.echo vbcrlf & " ShVerb - To many parameters" & vbcrlf & " Use quotes around filenames and verbs containing spaces" & vbcrlf 
     wscript.echo HelpMsg 
     wscript.quit 
    End If 

    If fso.DriveExists(Ag(0)) = True then 
     Set objFolder = objShell.Namespace(fso.GetFileName(Ag(0))) 
'  Set objFolderItem = objFolder.ParseName(fso.GetFileName(Ag(0))) 
     Set objFolderItem = objFolder.self 
     msgbox ag(0) 
    ElseIf fso.FolderExists(Ag(0)) = True then 
     Set objFolder = objShell.Namespace(fso.GetParentFolderName(Ag(0))) 
     Set objFolderItem = objFolder.ParseName(fso.GetFileName(Ag(0))) 
    ElseIf fso.fileExists(Ag(0)) = True then 
     Set objFolder = objShell.Namespace(fso.GetParentFolderName(Ag(0))) 
     Set objFolderItem = objFolder.ParseName(fso.GetFileName(Ag(0))) 
    Else 
     wscript.echo " ShVerb - " & Ag(0) & " not found" 
     wscript.echo HelpMsg 
     wscript.quit 
    End If 

    Set objVerbs = objFolderItem.Verbs 

    'If only one argument list verbs for that item 

    If Ag.count = 1 then 
     For Each cmd in objFolderItem.Verbs 
      If len(cmd) <> 0 then CmdList = CmdList & vbcrlf & replace(cmd.name, "&", "") 
     Next 
     wscript.echo mid(CmdList, 2) 

    'If two arguments do verbs for that item 

    ElseIf Ag.count = 2 then 
     For Each cmd in objFolderItem.Verbs 
      If lcase(replace(cmd, "&", "")) = LCase(Ag(1)) then 
       wscript.echo Cmd.doit 
       Exit For 
      End If 
     Next 
    'Properties is special cased. Script has to stay running for Properties dialog to show. 
     If Lcase(Ag(1)) = "properties" then 
      WSHShell.AppActivate(ObjFolderItem.Name & " Properties") 
      msgbox "This message box has to stay open to keep the " & ObjFolderItem.Name & " Properties dialog open." 
     End If 
    End If 
End If 
+0

啊!聰明。 +1。 – npocmaka 2014-09-25 20:45:32

+0

謝謝你的迴應。我已經嘗試過使用暫停。但在我的情況下,它不起作用。實際上,在批處理文件中,我正在做簡單的事情 - 1.進入exe文件位置2.打開所需的exe文件。當我不打開exe文件時,暫停效果很好。有什麼辦法可以解決這個問題嗎?謝謝。 – Arfeen 2014-09-25 21:18:16

+0

發佈您的批處理文件。 – Noodles 2014-09-25 21:22:32

相關問題