我一直在寻找获取硬盘序列号而不使用WMI,我发现它. The code I found and posted on StackOverFlow.com在32位Windows XP和Vista上都非常出色.只有当我尝试在64位操作系统上获得序列号(具体是Vista Ultimate 64)时才会出现这个问题.代码返回String.Empty,或者一直是空格.

任何人有一个想法如何解决这个问题?

编辑:

我用Dave Cluderay建议的工具,有趣的结果是:

这是diskID32的输出,在Windows XP SP2 32位上:

To get all details use "diskid32 /d"
Trying to read the drive IDs using physical access with admin rights
Drive 0 - Primary Controller -  - Master drive
Drive Model Number________________: [MAXTOR STM3160215AS]
Drive Serial Number_______________: [            6RA26XK3]
Drive Controller Revision Number__: [3.AAD]
Controller Buffer Size on Drive___: 2097152 bytes
Drive Type________________________: Fixed
Drive Size________________________: 160041885696 bytes

Trying to read the drive IDs using the SCSI back door

Drive 4 - Tertiary Controller -  - Master drive
Drive Model Number________________: [MAXTOR STM3160215AS]
Drive Serial Number_______________: [            6RA26XK3]
Drive Controller Revision Number__: [3.AAD]
Controller Buffer Size on Drive___: 2097152 bytes
Drive Type________________________: Fixed
Drive Size________________________: 160041885696 bytes

Trying to read the drive IDs using physical access with zero rights

**** STORAGE_DEVICE_DESCRIPTOR for drive 0 ****
vendor Id = []
Product Id = [MAXTOR STM3160215AS]
Product Revision = [3.AAD]
Serial Number = []

**** disK_GEOMETRY_EX for drive 0 ****
disk is fixed
diskSize = 160041885696

Trying to read the drive IDs using Smart

Drive 0 - Primary Controller -  - Master drive

Drive Model Number________________: [MAXTOR STM3160215AS]
Drive Serial Number_______________: [            6RA26XK3]
Drive Controller Revision Number__: [3.AAD]
Controller Buffer Size on Drive___: 2097152 bytes
Drive Type________________________: Fixed
Drive Size________________________: 160041885696 bytes

Hard Drive Serial Number__________:             6RA26XK3

Hard Drive Model Number___________: MAXTOR STM3160215AS

diskID32在Windows Vista Ultimate 64位运行:

To get all details use "diskid32 /d"

Trying to read the drive IDs using physical access with admin rights

Trying to read the drive IDs using the SCSI back door

Trying to read the drive IDs using physical access with zero rights

**** STORAGE_DEVICE_DESCRIPTOR for drive 0 ****
vendor Id = [MAXTOR S]
Product Id = [TM3160215AS]
Product Revision = [3.AA]
Serial Number = []

**** disK_GEOMETRY_EX for drive 0 ****
disk is fixed
diskSize = 160041885696

Trying to read the drive IDs using Smart

Hard Drive Serial Number__________:

Hard Drive Model Number___________:

请注意,Vista上的信息多少,以及如何不返回序列号.另一个工具Enumdisk是指Vista上的我的硬盘作为“SCSI”而不是Windows XP上的“ATA”.

有任何想法吗?

编辑2:

我发布了Enumdisks的结果:

在Windows XP SP2 32位上:

Properties for Device 1

Device ID: IDE\diskMAXTOR_STM3160215AS_____________________3.AAD___

Adapter Properties
------------------
Bus Type       : ATA
Max. Tr. Length: 0x20000
Max. Phy. Pages: 0xffffffff
Alignment Mask : 0x1

Device Properties
-----------------
Device Type     : Direct Access Device (0x0)
Removable Media : No
Product ID      : MAXTOR STM3160215AS
Product Revision: 3.AAD

Inquiry Data from Pass Through
------------------------------
Device Type: Direct Access Device (0x0)
vendor ID  : MAXTOR S
Product ID : TM3160215AS
Product Rev: 3.AA
vendor Str :



***  End of Device List  ***

在Vista 64 Ultimate:

Properties for Device 1

Device ID: SCSI\diskMAXTOR_STM3160215AS_____3.AA

Adapter Properties
------------------
Bus Type       : FIBRE
Max. Tr. Length: 0x20000
Max. Phy. Pages: 0x11
Alignment Mask : 0x0

Device Properties
-----------------
Device Type     : Direct Access Device (0x0)
Removable Media : No
vendor ID       : MAXTOR S
Product ID      : TM3160215AS
Product Revision: 3.AA

Inquiry Data from Pass Through
------------------------------
Device Type: Direct Access Device (0x0)
vendor ID  : MAXTOR S
Product ID : TM3160215AS
Product Rev: 3.AA
vendor Str :



***  End of Device List  ***
此代码尝试三次获取序列号:

>使用IOCTL_STORAGE_QUERY_PROPERTY.
>使用SMART_RCV_DRIVE_DATA.
>使用IOCTL_SCSI_PASS_THROUGH.

这段代码对我来说适用于64位:

' PhysicalDrive.vb

Option Strict On
Option Explicit On

Imports System.Runtime.InteropServices
Imports System.Text
Imports System.ComponentModel
Imports Microsoft.Win32.SafeHandles

Public Class PhysicalDrive

#Region "Win32 DeFinitions"
    <StructLayout(LayoutKind.Sequential)> _
    Private Structure IDEREGS
        Public bFeaturesReg As Byte
        Public bSectorCountReg As Byte
        Public bSectorNumberReg As Byte
        Public bCylLowReg As Byte
        Public bCylHighReg As Byte
        Public bDriveHeadReg As Byte
        Public bCommandReg As Byte
        Public bReserved As Byte
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure SENDCMDINParaMS
        Public cBufferSize As Int32
        Public irDriveRegs As IDEREGS
        Public bDriveNumber As Byte
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=3)> _
        Public bReserved As Byte()
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=4)> _
        Public dwReserved As Int32()
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=1)> _
        Public bBuffer As Byte()
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure DRIVERSTATUS
        Public bDriverError As Byte
        Public bIDEError As Byte
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=2)> _
        Public bReserved As Byte()
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=2)> _
        Public dwReserved As Int32()
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure SENDCMDOUTParaMS
        Public cBufferSize As Int32
        Public DriverStatus As DRIVERSTATUS
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=IDENTIFY_BUFFER_SIZE)> _
        Public bBuffer As Byte()
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure GETVERSIONINParaMS
        Public bVersion As Byte
        Public bRevision As Byte
        Public bReserved As Byte
        Public bIDEDeviceMap As Byte
        Public fCapabilities As Int32
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=4)> _
        Public dwReserved As Int32()
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure STORAGE_PROPERTY_QUERY
        Public PropertyId As Int32
        Public QueryType As Int32
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=1)> _
        Public AdditionalParameters As Byte()
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure STORAGE_DEVICE_DESCRIPTOR
        Public Version As Int32
        Public Size As Int32
        Public DeviceType As Byte
        Public DeviceTypeModifier As Byte
        Public RemovableMedia As Byte
        Public Commandqueueing As Byte
        Public vendorIdOffset As Int32
        Public ProductIdOffset As Int32
        Public ProductRevisionOffset As Int32
        Public SerialNumberOffset As Int32
        Public BusType As Byte
        Public RawPropertiesLength As Int32
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=10240)> _
        Public RawDeviceProperties As Byte()
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure SCSI_PASS_THROUGH
        Public Length As Int16
        Public ScsiStatus As Byte
        Public PathId As Byte
        Public TargetId As Byte
        Public Lun As Byte
        Public CdbLength As Byte
        Public SenseInfoLength As Byte
        Public DataIn As Byte
        Public DataTransferLength As Int32
        Public TimeOutValue As Int32
        Public DataBufferOffset As IntPtr
        Public SenseInfoOffset As Int32
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=16)> _
        Public Cdb As Byte()
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure SCSI_PASS_THROUGH_WITH_BUFFER
        Public Spt As SCSI_PASS_THROUGH
        Public Filler As Int32
        <MarshalAs(UnmanagedType.ByValArray,SizeConst:=64)> _
        Public Buffer As Byte()
    End Structure

    <DllImport("kernel32.dll",SetLastError:=True)> _
    Private Shared Function CreateFile(ByVal lpFileName As String,ByVal dwDesiredAccess As Int32,ByVal dwShareMode As Int32,ByVal lpSecurityAttributes As IntPtr,ByVal dwCreationdisposition As Int32,ByVal dwFlagsAndAttributes As Int32,ByVal hTemplateFile As IntPtr) As SafeFileHandle
    End Function

    <DllImport("kernel32.dll",SetLastError:=True)> _
    Private Shared Function DeviceIoControl(ByVal hDevice As SafeFileHandle,ByVal dwIoControlCode As Int32,<[In]()> ByRef lpInBuffer As SENDCMDINParaMS,ByVal nInBufferSize As Int32,<[In](),Out()> ByRef lpOutBuffer As SENDCMDOUTParaMS,ByVal nOutBufferSize As Int32,ByRef lpBytesReturned As Int32,ByVal lpOverlapped As Int32) As Int32
    End Function

    <DllImport("kernel32.dll",ByVal lpInBuffer As IntPtr,Out()> ByRef lpOutBuffer As GETVERSIONINParaMS,<[In]()> ByRef lpInBuffer As STORAGE_PROPERTY_QUERY,Out()> ByRef lpOutBuffer As STORAGE_DEVICE_DESCRIPTOR,<[In]()> ByRef lpInBuffer As SCSI_PASS_THROUGH_WITH_BUFFER,Out()> ByRef lpOutBuffer As SCSI_PASS_THROUGH_WITH_BUFFER,ByVal lpOverlapped As Int32) As Int32
    End Function

    Private Const OPEN_EXISTING As Int32 = 3
    Private Const GENERIC_READ As Int32 = &H80000000
    Private Const GENERIC_WRITE As Int32 = &H40000000
    Private Const FILE_SHARE_READ As Int32 = &H1
    Private Const FILE_SHARE_WRITE As Int32 = &H2
    Private Const FILE_SHARE_DELETE As Int32 = &H4
    Private Const SMART_GET_VERSION As Int32 = &H74080
    Private Const SMART_RCV_DRIVE_DATA As Int32 = &H7C088
    Private Const ID_CMD As Int32 = &HEC
    Private Const IDENTIFY_BUFFER_SIZE As Int32 = 512
    Private Const CAP_SMART_CMD As Int32 = &H4
    Private Const IOCTL_STORAGE_QUERY_PROPERTY As Int32 = &H2D1400
    Private Const IOCTL_SCSI_PASS_THROUGH As Int32 = &H4D004
    Private Const SCSI_IOCTL_DATA_IN As Int32 = &H1
    Private Const PropertyStandardQuery As Int32 = 0
    Private Const StorageDeviceProperty As Int32 = 0
    Private Const ERROR_INVALID_FUNCTION As Int32 = &H1
#End Region

    Public Shared Function GetSerialNumberUsingStorageQuery(ByVal diskNumber As Integer) As String
        Using hdisk As SafeFileHandle = Opendisk(diskNumber)
            Dim iBytesReturned As Int32
            Dim spq As New STORAGE_PROPERTY_QUERY()
            Dim sdd As New STORAGE_DEVICE_DESCRIPTOR()
            spq.PropertyId = StorageDeviceProperty
            spq.QueryType = PropertyStandardQuery

            If DeviceIoControl(hdisk,IOCTL_STORAGE_QUERY_PROPERTY,spq,Marshal.SizeOf(spq),sdd,Marshal.SizeOf(sdd),iBytesReturned,0) = 0 Then
                Throw CreateWin32Exception(Marshal.GetLastWin32Error(),"DeviceIoControl(IOCTL_STORAGE_QUERY_PROPERTY)")
            End If

            Dim result As New StringBuilder()
            If sdd.SerialNumberOffset > 0 Then
                Dim rawDevicePropertiesOffset As Integer = Marshal.SizeOf(sdd) - sdd.RawDeviceProperties.Length
                Dim pos As Integer = sdd.SerialNumberOffset - rawDevicePropertiesOffset
                While pos < iBytesReturned And sdd.RawDeviceProperties(pos) <> 0
                    result.Append(Encoding.ASCII.GetString(sdd.RawDeviceProperties,pos,1))
                    pos += 1
                End While
            End If
            Return result.ToString().Trim()
        End Using
    End Function

    Public Shared Function GetSerialNumberUsingSmart(ByVal diskNumber As Integer) As String
        Using hdisk As SafeFileHandle = Opendisk(diskNumber)
            If Issmartsupported(hdisk) Then
                Dim iBytesReturned As Int32
                Dim sci As New SENDCMDINParaMS
                Dim sco As New SENDCMDOUTParaMS
                sci.irDriveRegs.bCommandReg = ID_CMD
                sci.bDriveNumber = CByte(diskNumber)
                sci.cBufferSize = IDENTIFY_BUFFER_SIZE
                If DeviceIoControl(hdisk,SMART_RCV_DRIVE_DATA,sci,Marshal.SizeOf(sci),sco,Marshal.SizeOf(sco),0) = 0 Then
                    Throw CreateWin32Exception(Marshal.GetLastWin32Error(),"DeviceIoControl(SMART_RCV_DRIVE_DATA)")
                End If
                Dim result As New StringBuilder()
                For index As Integer = 20 To 39 Step 2
                    result.Append(Encoding.ASCII.GetString(sco.bBuffer,index + 1,1))
                    result.Append(Encoding.ASCII.GetString(sco.bBuffer,index,1))
                Next
                Return result.ToString().Trim()
            Else
                Return String.Empty
            End If
        End Using
    End Function

    Public Shared Function GetSerialNumberUsingScsiPassthrough(ByVal diskNumber As Integer) As String
        Using hdisk As SafeFileHandle = Opendisk(diskNumber)
            Dim iBytesReturned As Int32
            Dim spt As New SCSI_PASS_THROUGH_WITH_BUFFER
            spt.Spt.Length = CShort(Marshal.SizeOf(spt.Spt))
            spt.Spt.CdbLength = 16
            spt.Spt.DataIn = SCSI_IOCTL_DATA_IN
            spt.Spt.DataTransferLength = 64
            spt.Spt.DataBufferOffset = New IntPtr(Marshal.SizeOf(spt) - 64)
            spt.Spt.TimeOutValue = 60
            Dim cdb(15) As Byte
            cdb(0) = &H12 ' INQUIRY
            cdb(1) = &H1 ' EVPD bit
            cdb(2) = &H80 ' Page code (indicates Serial Number)
            cdb(4) = 64 ' Allocation length
            spt.Spt.Cdb = cdb
            If DeviceIoControl(hdisk,IOCTL_SCSI_PASS_THROUGH,spt,Marshal.SizeOf(spt),0) = 0 Then
                Dim iErrorCode As Int32 = Marshal.GetLastWin32Error()
                If iErrorCode <> ERROR_INVALID_FUNCTION Then
                    Throw CreateWin32Exception(iErrorCode,"DeviceIoControl(IOCTL_SCSI_PASS_THROUGH)")
                End If
            End If
            Dim result As New StringBuilder()
            Dim pos As Integer = IntPtr.Size
            While pos < spt.Spt.DataTransferLength And spt.Buffer(pos) <> 0
                result.Append(Encoding.ASCII.GetString(spt.Buffer,1))
                pos += 1
            End While
            Return result.ToString().Trim()
        End Using
    End Function

    Private Shared Function CreateWin32Exception(ByVal errorCode As Int32,ByVal context As String) As Win32Exception
        Dim win32Exception As New Win32Exception(errorCode)
        win32Exception.Data("Context") = context
        Return win32Exception
    End Function

    Private Shared Function Opendisk(ByVal diskNumber As Integer) As SafeFileHandle
        Dim hDevice As SafeFileHandle = CreateFile(String.Format("\\.\PhysicalDrive{0}",diskNumber),GENERIC_READ Or GENERIC_WRITE,FILE_SHARE_READ Or FILE_SHARE_WRITE Or FILE_SHARE_DELETE,IntPtr.Zero,OPEN_EXISTING,IntPtr.Zero)
        If (Not hDevice.IsInvalid) Then
            Return hDevice
        Else
            Throw CreateWin32Exception(Marshal.GetLastWin32Error(),"CreateFile")
        End If
    End Function

    Private Shared Function Issmartsupported(ByVal hdisk As SafeFileHandle) As Boolean
        Dim iBytesReturned As Int32
        Dim gvi As New GETVERSIONINParaMS
        If DeviceIoControl(hdisk,SMART_GET_VERSION,gvi,Marshal.SizeOf(gvi),0) = 0 Then
            Return False
        End If
        Return (gvi.fCapabilities And CAP_SMART_CMD) > 0
    End Function

End Class

这里的代码叫做:

' MainModule.vb

Module MainModule

    Sub Main()
        Console.WriteLine("{0}-bit runtime.",IntPtr.Size * 8)
        For drive As Integer = 0 To 4
            Try
                Console.WriteLine("Drive {0},SMART:             [{1}]",drive,PhysicalDrive.GetSerialNumberUsingSmart(drive))
                Console.WriteLine("Drive {0},Storage Query:     [{1}]",PhysicalDrive.GetSerialNumberUsingStorageQuery(drive))
                Console.WriteLine("Drive {0},SCSI Pass Through: [{1}]",PhysicalDrive.GetSerialNumberUsingScsiPassthrough(drive))
            Catch ex As Exception
                If ex.Data("Context") IsNot nothing Then Console.Error.Write("{0} Failed: ",ex.Data("Context"))
                Console.Error.WriteLine(ex.Message)
            End Try
        Next
    End Sub

End Module

编辑 – 我改变了主要方法来显示每个尝试的结果进行比较.这将有助于说明这些技术的命中和想法.

windows-vista – 获取Vista Ultimate 64位的HDD(和NOT Volume)序列号的更多相关文章

  1. windows.h中的WINVER和_WIN32_WINNT警卫怎么了?

    任何人都可以推荐一种可靠的方法来确定哪个版本的Windows引入了哪些API功能?

  2. Windows – .NET应用程序中的Vista异常“异常处理消息”

    BackgroundI在4.0Framework上构建了一个VB.NET应用程序,主要功能的一部分是内置的AxWMPLib.AxWindowsMediaPlayer,它允许我们将文件路径作为URL传递给播放器,然后通过内置的媒体播放器播放.我的开发平台是Windows7上的VS2010Pro.问题我们最近开始在多个操作系统上测试这个应用程序.应用程序在多个win7机器上的Win7上运行良好,一些用

  3. .net – 从开发角度来看:如何让老板们升级到Vista / Windows 7?

    我们当前的开发环境是WindowsXP专业版.这是一个很好的操作系统,但在家里使用Vista和Windows7之后,我发现自己想在工作中使用它们,我将大部分时间花在电脑上.问题在于WindowsXP能够完成这项工作,并且显然它已经到位并且有效,但是前进的成本是0,而Vista/Windows7显然会在短期内花费金钱和时间,但我相信从长远来看我们在Vista或7环境中都会更有效率.所以我的问题是如何

  4. 如何快速测试Windows小工具?

    如何在开发过程中快速测试WindowsGadget?创建存档,安装存档并每次将其添加到桌面都非常繁琐……

  5. Nant在Windows Vista 64上

    我想知道是否有人在WindowsVista64位版本上成功运行Nant.它一直在失败设置道具:[sysinfo]在sys.下设置系统信息属性建筑失败属性名称“sys.env.CommonProgramFiles(x86)”无效.是的,它有效.默认情况下,NAnt是为32位构建的.因此,必须记住在32位命令提示符或PowerShell中运行它.我在Vista64计算机上运行PowerShell(x8

  6. .NET上是否默认安装了.NET Framework?

    我正在编写一个控制台应用程序,它将与我们正在编写的应用程序的安装一起部署.控制台应用程序旨在修复Vista中的错误,以便我们的应用程序可以在Vista中正确安装.控制台应用程序运行正常,但我可以依靠所有Vista机器上安装的.NET框架–它是否默认安装?

  7. windows-7 – 如何签署我的驱动,所以它会安装在Windows 7 64位?

    我需要从Microsoft获得证书吗?我已经开发了驱动程序,现在正在使它在64位机器上工作…

  8. 命令行 – 导致xcopy告诉我访问被拒绝的原因是什么?

    我们的一个解决方案的postbuild任务使用xcopy将文件移动到共同的目录中以构建工件.由于某些原因,在我的计算机上,xcopy将失败,而“拒绝访问”.以下是我为尝试隔离问题所做的工作:我试过正常的副本;这个工作.>我仔细检查,没有一个文件是只读的.我检查了源文件夹和目标文件夹的权限;我完全控制了两者.>我尝试从命令行调用xcopy,以防VS构建过程锁定文件.>我使用Unlocker和ProcessExplorer来确定源文件上没有锁.我错过了什么,除了涉及电脑的偏执狂阴谋理论让我?

  9. windows-vista – 获取Vista Ultimate 64位的HDD(和NOT Volume)序列号

    我一直在寻找获取硬盘序列号而不使用WMI,我发现它.ThecodeIfoundandpostedonStackOverFlow.com在32位WindowsXP和Vista上都非常出色.只有当我尝试在64位操作系统上获得序列号(具体是VistaUltimate64)时才会出现这个问题.代码返回String.Empty,或者一直是空格.任何人有一个想法如何解决这个问题?编辑:我用DaveCluder

  10. Windows上的Python性能

    Windows与*nix机器上的Python通常较慢?

随机推荐

  1. static – 在页面之间共享数据的最佳实践

    我想知道在UWP的页面之间发送像’selectedItem’等变量的最佳做法是什么?创建一个每个页面都知道的静态全局变量类是一个好主意吗?

  2. .net – 为Windows窗体控件提供百分比宽度/高度

    WindowsForm开发的新手,但在Web开发方面经验丰富.有没有办法为Windows窗体控件指定百分比宽度/高度,以便在用户调整窗口大小时扩展/缩小?当窗口调整大小时,可以编写代码来改变控件的宽度/高度,但我希望有更好的方法,比如在HTML/CSS中.在那儿?

  3. 使用Windows Azure查询表存储数据

    我需要使用特定帐户吗?>将应用程序部署到Azure服务后,如何查询数据?GoogleAppEngine有一个数据查看器/查询工具,Azure有类似的东西吗?>您可以看到的sqlExpressintance仅在开发结构中,并且一旦您表示没有等效,所以请小心使用它.>您可以尝试使用Linqpad查询表格.看看JamieThomson的thispost.

  4. windows – SetupDiGetClassDevs是否与文档中的设备实例ID一起使用?

    有没有更好的方法可以使用DBT_DEVICEARRIVAL事件中的数据获取设备的更多信息?您似乎必须指定DIGCF_ALLCLASSES标志以查找与给定设备实例ID匹配的所有类,或者指定ClassGuid并使用DIGCF_DEFAULT标志.这对我有用:带输出:

  5. Windows Live ID是OpenID提供商吗?

    不,WindowsLiveID不是OpenID提供商.他们使用专有协议.自从他们的“测试版”期结束以来,他们从未宣布计划继续它.

  6. 如果我在代码中进行了更改,是否需要重新安装Windows服务?

    我写了一个Windows服务并安装它.现在我对代码进行了一些更改并重新构建了解决方案.我还应该重新安装服务吗?不,只需停止它,替换文件,然后重新启动它.

  7. 带有双引号的字符串回显使用Windows批处理输出文件

    我正在尝试使用Windows批处理文件重写配置文件.我循环遍历文件的行并查找我想要用指定的新行替换的行.我有一个’函数’将行写入文件问题是%Text%是一个嵌入双引号的字符串.然后失败了.可能还有其他角色也会导致失败.如何才能使用配置文件中的所有文本?尝试将所有“在文本中替换为^”.^是转义字符,因此“将被视为常规字符你可以尝试以下方法:其他可能导致错误的字符是:

  8. .net – 将控制台应用程序转换为服务?

    我正在寻找不同的优势/劣势,将我们长期使用的控制台应用程序转换为Windows服务.我们为ActiveMQ使用了一个叫做java服务包装器的东西,我相信人们告诉我你可以用它包装任何东西.这并不是说你应该用它包装任何东西;我们遇到了这个问题.控制台应用程序是一个.NET控制台应用程序,默认情况下会将大量信息记录到控制台,尽管这是可配置的.任何推荐?我们应该在VisualStudio中将其重建为服务吗?我使用“-install”/“-uninstall”开关执行此操作.例如,seehere.

  9. windows – 捕获外部程序的STDOUT和STDERR *同时*它正在执行(Ruby)

    哦,我在Windows上:-(实际上,它比我想象的要简单,这看起来很完美:…是的,它适用于Windows!

  10. windows – 当我试图批量打印变量时,为什么我得到“Echo is on”

    我想要执行一个简单的批处理文件脚本:当我在XP中运行时,它给了我预期的输出,但是当我在Vista或Windows7中运行它时,我在尝试打印值时得到“EchoisOn”.以下是程序的输出:摆脱集合表达式中的空格.等号(=)的两侧可以并且应该没有空格BTW:我通常在@echo关闭的情况下启动所有批处理文件,并以@echo结束它们,所以我可以避免将代码与批处理文件的输出混合.它只是使您的批处理文件输出更好,更清洁.

返回
顶部