Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何更新此.HTA以在Win7中使用_C++_Csv_Windows 7 X64_Hta - Fatal编程技术网

C++ 如何更新此.HTA以在Win7中使用

C++ 如何更新此.HTA以在Win7中使用,c++,csv,windows-7-x64,hta,C++,Csv,Windows 7 X64,Hta,我有一个HTA,我们用它来收集服务器的磁盘空间,它将这些信息导出到CSV文件中。由于我们升级到Win7,它将不会导出,因为它使用WinXP“SAFRCFileDlg.FileSave”。我正在寻找一种在Win7中使用此HTA的方法,但我需要知道如何绕过此XP脚本。我无法从xp添加dll 我想发布整个脚本,以便您可以看到其中涉及的所有内容。问题在于“次级出口”。任何帮助都将不胜感激。这个脚本很好用,它很好地显示了所有的信息,但是我不能让它导出数据 Sub DiskSpace 'On Error

我有一个HTA,我们用它来收集服务器的磁盘空间,它将这些信息导出到CSV文件中。由于我们升级到Win7,它将不会导出,因为它使用WinXP“SAFRCFileDlg.FileSave”。我正在寻找一种在Win7中使用此HTA的方法,但我需要知道如何绕过此XP脚本。我无法从xp添加dll

我想发布整个脚本,以便您可以看到其中涉及的所有内容。问题在于“次级出口”。任何帮助都将不胜感激。这个脚本很好用,它很好地显示了所有的信息,但是我不能让它导出数据

Sub DiskSpace

'On Error Resume Next

strComputer = WriteDiskSpace.Value

Document.getElementById("WriteDiskSpace1").innerhtml = ""

Set objOption = Document.createElement("OPTION")
    objOption.Text = "---------------------------------------"
    objOption.Value = "--------------------------------------"
    WriteDiskSpace1.Add(objOption)
Set objOptionA = Document.createElement("OPTION")
    objOptionA.Text = strComputer
    objOptionA.Value = strComputer
    WriteDiskSpace1.Add(objOptionA)
Set objOptionB = Document.createElement("OPTION")
    objOptionB.Text = "---------------------------------------"
    objOptionB.Value = "--------------------------------------"
    WriteDiskSpace1.Add(objOptionB)

Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_Volume")
For Each objItem in colItems

If objItem.Capacity > "" then

'Total Space in TeraBytes
strDiskGB = Int(objItem.Capacity /1073741824)
strDiskTB = ABS(strDiskGB /1028)
strDiskSubTotal = Int(strDiskTB * 1000)
strDiskTotal = ABS(strDiskSubTotal / 1000)

'Total Used Space in TeraBytes
strUsedGB = Int((objItem.Capacity - objItem.FreeSpace)/ 1073741824)
strUsedTB = ABS(strUsedGB /1028)
strUsedSubTotal = Int(strUsedTB * 1000)
strUsedTotal = ABS(strUsedSubTotal / 1000)

'Total Free Space
 strFreeGB = Int(objItem.FreeSpace /1073741824)
strFreeTB = ABS(strFreeGB /1028)
strFreeSubTotal = Int(strFreeTB * 1000)
strFreeTotal = ABS(strFreeSubTotal / 1000)

strTitle1 = "Volume : "
strTitle2 = "Total Space : "
strTitle3 = "Used Space : "
strTitle4 = "Free Space : "
strTitle5 = "Free Percentage : "

strText1 = strTitle1 & objItem.Name
strText2 = strTitle2 & strDiskTotal & " TB"
strText3 = strTitle3 & strUsedTotal & " TB"
strtext4 = strTitle4 & strFreeTotal & " TB"
strText5 = strTitle5 & Round((objItem.FreeSpace /objItem.Capacity)*100,2) & " %"

Set objOption1 = Document.createElement("OPTION")
objOption1.Text = strText1
objOption1.Value = strText1
WriteDiskSpace1.Add(objOption1)

Set objOption7 = Document.createElement("OPTION")
objOption7.Text = ""
objOption7.Value = ""
WriteDiskSpace1.Add(objOption7)

Set objOption2 = Document.createElement("OPTION")
objOption2.Text = strText2
objOption2.Value = strText2
WriteDiskSpace1.Add(objOption2)

Set objOption3 = Document.createElement("OPTION")
objOption3.Text = strText3
objOption3.Value = strText3
WriteDiskSpace1.Add(objOption3)

Set objOption4 = Document.createElement("OPTION")
objOption4.Text = strText4
objOption4.Value = strText4
WriteDiskSpace1.Add(objOption4)

Set objOption5 = Document.createElement("OPTION")
objOption5.Text = strText5
objOption5.Value = strText5
WriteDiskSpace1.Add(objOption5)

Set objOption6 = Document.createElement("OPTION")
objOption6.Text = ""
objOption6.Value = ""
WriteDiskSpace1.Add(objOption6)

Else    
End If

Next

End Sub         
“好的,好的,好的” 转口

strArray = Array("Server", "Server", "Server", "Server", "Server")

Set objDialog = CreateObject("SAFRCFileDlg.FileSave")
objDialog.FileName = "Storage_Data.CSV"
objDialog.FileType = "CSV File"
intResult = objDialog.OpenFileSaveDlg

If intResult Then
Set objFSo = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(objDialog.FileName)
objFile.Close

Else
Exit Sub
End If

Set objFSo = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(objDialog.FileName)
objFile.Close

For Each ComArr in strArray

strComputer = ComArr

Set objFSo = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(objDialog.FileName, 8, True)
        objFile.WriteLine "SERVER NAME,Volume,Total Space,,Used Space,,Free Space,,Free         Percentage"
objFile.WriteLine strComputer
objFile.Close

On Error Resume Next

Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_Volume")
For Each objItem in colItems

If objItem.Capacity > "" then

'Total Space in TeraBytes
strDiskGB = Int(objItem.Capacity /1073741824)
strDiskTB = ABS(strDiskGB /1028)
strDiskSubTotal = Int(strDiskTB * 1000)
strDiskTotal = ABS(strDiskSubTotal / 1000)

'Total Used Space in TeraBytes
strUsedGB = Int((objItem.Capacity - objItem.FreeSpace)/ 1073741824)
strUsedTB = ABS(strUsedGB /1028)
strUsedSubTotal = Int(strUsedTB * 1000)
strUsedTotal = ABS(strUsedSubTotal / 1000)

'Total Free Space
strFreeGB = Int(objItem.FreeSpace /1073741824)
strFreeTB = ABS(strFreeGB /1028)
strFreeSubTotal = Int(strFreeTB * 1000)
strFreeTotal = ABS(strFreeSubTotal / 1000)

strText1 = objItem.Name
strText2 = strDiskTotal & ", TB"
strText3 = strUsedTotal & ", TB"
strtext4 = strFreeTotal & ", TB"
strText5 = Round((objItem.FreeSpace /objItem.Capacity)*100,2) & " %"

Set objFSo = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(objDialog.FileName, 8, True)
objFile.WriteLine "," & strText1 & "," & strText2 & "," & strText3 & "," & strText4 & "," & strText5
objFile.Close

Else
End If
Next
Next
End Sub
“好的,好的,好的” 亚总体空间

Document.getElementById("WriteDiskSpace1").innerhtml = ""

strArray = Array("Server", "Server", "Server", "Server", "Server", "Server")

For Each ComArr in strArray

strComputer = ComArr

Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_Volume")
For Each objItem in colItems

If objItem.Capacity > "" then

'Total Space in TeraBytes
strDiskGB = Int(objItem.Capacity /1073741824)
strDiskTB = ABS(strDiskGB /1028)
strDiskSubTotal = Int(strDiskTB * 1000)
strDiskTotal = ABS(strDiskSubTotal / 1000)

'Total Used Space in TeraBytes
strUsedGB = Int((objItem.Capacity - objItem.FreeSpace)/ 1073741824)
strUsedTB = ABS(strUsedGB /1028)
strUsedSubTotal = Int(strUsedTB * 1000)
strUsedTotal = ABS(strUsedSubTotal / 1000)

'Total Free Space
strFreeGB = Int(objItem.FreeSpace /1073741824)
strFreeTB = ABS(strFreeGB /1028)
strFreeSubTotal = Int(strFreeTB * 1000)
strFreeTotal = ABS(strFreeSubTotal / 1000)

strTotalStorage = ABS(strTotalStorage + strDiskTotal)
strTotalUsed = ABS(strTotalUsed + strUsedTotal)
strTotalFree = ABS(strTotalFree + strFreeTotal)

Else
End If

If objItem.Name = "C:\" then

strTotalStorage = ABS(strTotalStorage - strDiskTotal)
strTotalUsed = ABS(strTotalUsed - strUsedTotal)
strTotalFree = ABS(strTotalFree - strFreeTotal)

Else

End If
Next
Next

Set objOption = Document.createElement("OPTION")
objOption.Text = "Total : " & strTotalStorage & " TB"
objOption.Value = "Total : " & strTotalStorage & " TB"
WriteDiskSpace1.Add(objOption)

Set objOption1 = Document.createElement("OPTION")
objOption1.Text = "Used : " & strTotalUsed & " TB"
objOption1.Value = "Used : " & strTotalUsed & " TB"
WriteDiskSpace1.Add(objOption1)

Set objOption2 = Document.createElement("OPTION")
objOption2.Text = "Free : " & strTotalFree & " TB"
objOption2.Value = "Free : " & strTotalFree & " TB"
WriteDiskSpace1.Add(objOption2)

End Sub
“好的,好的,好的”


如果是HTA,将其添加到身体的某个地方

<OBJECT id=Dlg classid="CLSID:3050F4E1-98B5-11CF-BB82-00AA00BDCE0B" width=0 height=0>

也许现在是时候迈出这一步了,我想了很多!我希望这将需要一点调整,并恢复正常。我简单地涉猎了PS,我能够找出如何收集一些信息并将其导出到“gridview”中,但它没有excel那么好。我无法将此脚本的大部分翻译为PS。您可以查看以下链接:
strUPath = objShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop"
strStartPath = strUPath & "\Select a file"
strFilter = "Text (*.txt;*.csv)| *.txt;*.csv|VBScript (*.vbs;*.vbc)|*.vbs;*.vbc|HTML (*.htm;*.html;*.hta)|*.htm;*.html;*.hta|All Files (*.*)|*.*|"
strCaption = "Select a File to Replace"
strSelectedFile = Dlg.openfiledlg(CStr(strStartPath), , CStr(strFilter), CStr(strCaption))