2014-05-13 8 views
0

서버 디스크 공간을 수집하는 데 사용하는 HTA를 가지고 있으며 해당 정보를 CSV 파일로 내 보냅니다. Win7로 업그레이드 한 이후 WinXP "SAFRCFileDlg.FileSave"를 사용하기 때문에 내보내지지 않습니다. Win7에서이 HTA를 사용하는 방법을 찾고 있는데이 XP 스크립트를 해결하기 위해 내가 할 수있는 일이 무엇인지 알아야합니다. xp에서 dll을 추가 할 수 없습니다.어떻게이 .HTA를 Win7에서 사용하도록 업데이트 할 수 있습니까?

전체 스크립트를 게시하여 관련 스크립트를 모두 볼 수 있도록하고 싶습니다. 문제는 "Sub Export"에 있습니다. 어떤 도움을 주시면 감사하겠습니다. 이 스크립트는 사용하기 쉽고 멋지지만 모든 정보를 훌륭하게 표시하지만 데이터를 내보낼 수는 없습니다.

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 

'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' 서브 TotalSpace

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 

가 '' '' '' '' '' '' '' '' '' '' '' ''을 "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" '' '

+0

아마도 지금 [파워 쉘 (http://technet.microsoft.com/library/bb978526.aspx) – Mgetz

+0

내가 그 ... 많은 생각을 가지고 도약을 할 수있는 시간이다! 나는 이것이 조금 비틀고 정상으로 돌아 가기를 바랐다. 추신 : 간단히 말하면, 몇 가지 정보를 모아 "gridview"로 내보내는 방법을 알아낼 수 있었지만,이 스크립트의 대부분을 추신으로 번역 할 수 없었습니다. – taylorjb

+0

이 링크를 살펴볼 수 있습니다 : ** [시작 폴더 및 필터와 함께 파일 대화 상자 (w95에서 w8까지)의 절대적인 찾기]] (http://www.visualbasicscript.com/the-absolute-ultimate-Browse-for- 파일 대화 상자 -w95-to-w8-start-folder-and-filters-m104864.aspx) ** – Hackoo

답변

0

HTA 인 경우 본문의 어딘가에 추가하십시오.

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

그런 다음이 코드를 사용하여 대화 상자를 엽니 다.

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))