大网数据广告活动
网络与域名解析

Writing a Script to Configure the Virtual Directory

· 52CE 我爱测

Writing a Script to Configure the Virtual Directory

You can use the default BITS IIS property values to upload a file to the server. The upload file is written to the URL as specified in the remote file name of the job. To upload the file to a server application and receive a reply, change the BITSServerNotificationType property to send the data by reference (sends the name of the file that contains the data) or by value (sends the data in the body of the request).

For a list and description of the properties that you can modify, see BITS IIS Extension Properties. Use the methods of the IBITSExtensionSetup interface to enable and disable the virtual directory for uploads.

The following example shows how to use Windows Script Host to create, configure, and enable an IIS virtual directory for BITS uploads.

if (WScript.Arguments.length < 2)
{
    WScript.Echo("Usage: bitsvdir virtual_directory local_directory");
    WScript.Quit(1);
}

VirtualDirectoryName = WScript.Arguments(0);
LocalDirectoryName = WScript.Arguments(1);

ServerObj = GetObject("IIS://LocalHost/W3SVC/1/ROOT");
VirtualDir = ServerObj.Create("IIsWebVirtualDir", VirtualDirectoryName );

VirtualDir.Path = LocalDirectoryName;
VirtualDir.AppIsolated = 0;
VirtualDir.AccessScript = true;
VirtualDir.AccessRead = false;
VirtualDir.AccessWrite = false;
VirtualDir.SetInfo();

//Set BITS specific IIS configuration settings
VirtualDir.EnableBITSUploads();
VirtualDir.BITSMaximumUploadSize = "4294967296";
VirtualDir.SetInfo();

WScript.Echo( "Created virtual directory " + VirtualDirectoryName + 
              " with a local directory of " + LocalDirectoryName );
WScript.Quit( 0 );

To change the previous example to upload the data to a server application, add the following code before SetInfo.

VirtualDir.BITSServerNotificationType = 1;
VirtualDir.BITSServerNotificationURL = "https://myserver/mypath/myasp.asp";

The location of the upload file is passed to the server application, myasp.asp, in the BITS-Request-DataFile-Name header. To receive the upload file in the body of the request, set the BITSServerNotificationType property to 2.

For information on receiving the upload data in your server application, see Using BITS Notification Request/Response Headers.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。