自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

ASP.NET環(huán)境下的Shell函數(shù)

開(kāi)發(fā) 后端
本文向您介紹ASP.NET環(huán)境下的CMD命令的執(zhí)行,主要講解Shell函數(shù)的執(zhí)行選型和相關(guān)參數(shù),

Shell 函數(shù)

命名空間:Microsoft.VisualBasic

模塊:Interaction

程序集:Microsoft Visual Basic .NET 運(yùn)行庫(kù)(位于 Microsoft.VisualBasic.dll 中)

ASP.NET環(huán)境下運(yùn)行一個(gè)可執(zhí)行程序,并且如果該程序仍然在運(yùn)行,則返回一個(gè)包含該程序的進(jìn)程 ID 的整數(shù)。

  1. Public Function Shell( _   
  2. ByVal Pathname As String, _   
  3. Optional ByVal Style As   
  4. AppWinStyle = AppWinStyle.MinimizedFocus, _   
  5. Optional ByVal Wait As Boolean = False, _   
  6. Optional ByVal Timeout As Integer = -1 _   
  7. As Integer 

參數(shù)

Pathname

必選項(xiàng)。字符串。要執(zhí)行的程序名以及任何需要的參數(shù)和命令行開(kāi)關(guān)。Pathname 還可以包括驅(qū)動(dòng)器和目錄路徑或文件夾。

Style

可選項(xiàng)。AppWinStyle。從 AppWinStyle 枚舉中選擇的值,該枚舉與要在其中運(yùn)行程序的窗口樣式相對(duì)應(yīng)。如果省略 Style,則Shell函數(shù) 使用 AppWinStyle.MinimizedFocus,這將使程序以最小化啟動(dòng)并具有焦點(diǎn)。

Style 參數(shù)可以有以下設(shè)置之一:

枚舉值 說(shuō)明

AppWinStyle.Hide 隱藏窗口并為隱藏的窗口提供焦點(diǎn)。

AppWinStyle.NormalFocus 為窗口提供焦點(diǎn),并以最近的大小和位置顯示窗口。

AppWinStyle.MinimizedFocus 為窗口提供焦點(diǎn),并以圖標(biāo)的形式顯示窗口。

AppWinStyle.MaximizedFocus 為窗口提供焦點(diǎn),并以全屏方式顯示窗口。

AppWinStyle.NormalNoFocus 將窗口設(shè)置為最近的大小和位置。當(dāng)前活動(dòng)窗口保持焦點(diǎn)。

AppWinStyle.MinimizedNoFocus 以圖標(biāo)的形式顯示窗口。當(dāng)前活動(dòng)窗口保持焦點(diǎn)。

Wait

可選項(xiàng)。Boolean。指示 Shell 函數(shù)是否應(yīng)等待程序完成的值。如果省略 Wait,則 Shell 使用 False。

Timeout

可選項(xiàng)。Integer。Wait 為 True 時(shí)等待完成的毫秒數(shù)。如果省略 Timeout,則 Shell 使用 -1,表示沒(méi)有超時(shí),Shell 直到程序完成時(shí)才返回。因此,如果省略 Timeout 或?qū)⑺O(shè)置為 -1,則 Shell 函數(shù)可能永遠(yuǎn)不會(huì)將控制返回給程序。

現(xiàn)在看核心代碼:

  1. dim but as string   
  2. dim tempfile as   
  3. string=server.MapPath(".") & "\" & "test.txt"   
  4. shell("cmd.exe /c " & cmd.text & " > "   
  5. & tempfile,,true,-1)   
  6. dim myread as new streamreader  
  7. (tempfile,encoding.default)   
  8. but=myread.readtoend   
  9. but=replace(but,"<","<")   
  10. but=replace(but,">",">")   
  11. result.text="   
  12. " & but & "   
  13. "   
  14. myread.close   
  15. if file.exists(tempfile) then   
  16. file.delete(tempfile)   
  17. end if 

關(guān)鍵是shell函數(shù)("cmd.exe /c " & cmd.text & " > " & tempfile,,true,20000),這句話就是調(diào)用cmd.exe并且等待程序執(zhí)行完畢。注意:要是你運(yùn)行的命令需要等待(如date),那就慘了。那就暫時(shí)刪不掉臨時(shí)文件test.txt……而且不能再執(zhí)行命令了……不知道高手能不能解決這個(gè)問(wèn)題。

【編輯推薦】

  1. 淺析ASP.NET授權(quán)模塊
  2. 介紹ASP.NET MVC框架
  3. 配置ASP.NET AJAX概述
  4. ASP.NET頁(yè)面靜態(tài)化四步走
  5. ASP.NET頁(yè)面請(qǐng)求原理淺析
    責(zé)任編輯:冰荷 來(lái)源: ctocio
    相關(guān)推薦

    2009-07-23 13:09:23

    2009-08-10 18:19:37

    ASP.NET安裝環(huán)境

    2015-12-28 10:30:03

    UbuntuASP.NET環(huán)境

    2009-07-28 17:02:10

    ASP.NET運(yùn)行環(huán)境

    2009-08-10 18:24:29

    ASP.NET開(kāi)發(fā)環(huán)境

    2011-01-04 09:37:36

    2009-07-22 17:45:35

    ASP.NET教程

    2009-08-03 14:22:33

    什么是ASP.NET

    2009-07-28 17:17:19

    ASP.NET概述

    2009-07-27 12:22:03

    ASP.NET和ASPASP.NET入門教程

    2009-07-27 10:35:33

    TypeConvertASP.NET

    2009-07-29 11:19:03

    JavaScriptASP.NET

    2009-07-29 14:52:12

    IScriptContASP.NET

    2009-07-29 16:33:28

    GreeterLogiASP.NET

    2009-07-27 15:48:43

    2009-07-31 11:45:42

    ASP.NET文件下載

    2009-08-03 14:39:25

    Asp.Net函數(shù)集

    2010-03-03 17:12:56

    Ubuntu ASP.

    2009-08-10 13:32:15

    ASP.NET TimASP.NET組件設(shè)計(jì)

    2009-07-29 17:11:25

    ASP.NET ISA
    點(diǎn)贊
    收藏

    51CTO技術(shù)棧公眾號(hào)