我正在使用resize.exe的命令行版本(一个调整图像大小的程序)
我正在尝试创建一个简单的HTA应用程序,它将接收用户输入并将其传递给CMD。这里的问题是我的批处理脚本在将其放入VBS时失败。
我是逃避这个错误还是还有其他需要添加的东西?
var dt = new System.Data.DataTable();
dt.Columns.Add("Series", typeof(string));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Value", typeof(string));
//looping through SQL datasource for first series
while(){
dt.Rows.Add("Today", date, value);
}
//looping through SQL datasource for second series
while(){
dt.Rows.Add("Yesterday", date, value);
}
Chart1.Series.Clear();
Chart1.DataBindCrossTable(dt.Rows, "Series", "Date", "Value", "");
答案 0 :(得分:1)
我刚刚下载了 Resize.exe ,我在我的电脑上进行了一些小批量的测试,它与这批产品一起工作5/5,我知道你标记为HTA,所以只测试一下批处理,我将尝试将其集成到HTA上。
暂时试试这批产品:
@echo off
Title Batch Photos ReSizer
set RootFolder=C:\hta
set InputFolder=C:\hta\Photos\
set OutputFolder=%RootFolder%\Resized-photos
set /p Width=Choose the Width :
set /p Height=Choose the Height :
echo.
echo You have choosen to resize your photos in this resolution %Width%x%Height%
echo.
pause
echo. & echo Resizing photos is in Progress ...
if not exist %OutputFolder% MD %OutputFolder%
for /r %InputFolder% %%A in (*) do ("C:\hta\resize.exe" -i"%InputFolder%\%%~nxA" -o"%OutputFolder%\%%~nxA" -s%Width%x%Height%)
pause
Start Explorer "%OutputFolder%"
答案 1 :(得分:0)
以下是可以编写批处理文件并执行它的HTA:
<html>
<head>
<title>HTA Photos Resizer by Hackoo</title>
<HTA:APPLICATION
SCROLL="no"
ICON="nslookup.exe"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="no"
CAPTION="yes"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="yes"
SYSMENU="yes"
BORDER="thin"
BORDERSTYLE="Normal"
CONTEXTMENU="no"
SELECTION="no">
<style type="text/css">
body {
font-family:Verdana;
font-size: 12px;
color: #49403B;
background: Cyan;
text-align: center;
}
</style>
</head>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<SCRIPT LANGUAGE="VBScript">
Option Explicit
Dim Title,fso
Title = "HTA to Batch Resizer Photos by Hackoo"
Set fso = CreateObject("Scripting.FileSystemObject")
Sub Window_OnLoad()
CenterWindow 350,260
If Not fso.FileExists("resize.exe") Then
MsgBox "You must check "& DblQuote("resize.exe") &" is in the same folder of this HTA",VbCritical+VbSystemModal,Title
Exit Sub
End If
End Sub
'************************************************************************************************
Sub CenterWindow(x,y)
Dim iLeft,itop
window.resizeTo x,y
iLeft = window.screen.availWidth/2 - x/2
itop = window.screen.availHeight/2 - y/2
window.moveTo ileft,itop
End Sub
'************************************************************************************************
Sub ResizePhotos()
Dim Title,fso,InputFolder,ParentFolder,OutputFolder,MyTab,height,width,objOutputFile,BatchFile,WshShell,Exec
Title = "HTA to Batch Resizer Photos by Hackoo"
BatchFile = "Resizer.bat"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = fso.OpenTextFile(BatchFile,2,True)
height = h.Value
width = w.Value
InputFolder = TxtInputFolder.value
If InputFolder = "" Then
MsgBox "You must select the source folder",VbCritical+VbSystemModal,Title
Exit Sub
End If
ParentFolder = fso.GetParentFolderName(InputFolder)
MyTab = Split(InputFolder,"\")
OutPutFolder = ParentFolder & "\" & MyTab(UBound(MyTab)) & "_Resized"
objOutputFile.WriteLine "@echo off & mode con cols=70 lines=6 & color 9B"
objOutputFile.WriteLine "Title Batch Photos ReSizer"
objOutputFile.WriteLine "set InputFolder="& InputFolder &""
objOutputFile.WriteLine "set OutputFolder="& OutPutFolder &""
objOutputFile.WriteLine "echo."
objOutputFile.WriteLine "echo You have choosen to resize your photos in this resolution "& width &"x"& height &""
objOutputFile.WriteLine "echo."
objOutputFile.WriteLine "pause"
objOutputFile.WriteLine "Cls & echo. & echo Resizing photos is in Progress ..."
objOutputFile.WriteLine "if not exist %OutputFolder% MD %OutputFolder%"
objOutputFile.WriteLine "for /r "& DblQuote(InputFolder) &" %%A in (*) do (resize.exe -i"& DblQuote(InputFolder &"\%%~nxA") &" -o"& DblQuote(OutputFolder &"\%%~nxA")&" -s"& width&"x"& height &")"
objOutputFile.WriteLine "Start Explorer ""%OutputFolder%"""
objOutputFile.Close
Set objOutputFile = Nothing
Set WshShell = CreateObject("WScript.Shell")
Exec = WshShell.Run(BatchFile,1,True)
fso.DeleteFile BatchFile
End Sub
'***********************************************************************
Function PickFolder(strStartDir)
Dim SA,F
Set SA = CreateObject("Shell.Application")
Set F = SA.BrowseForFolder(0,"Choose the source folder",1,strStartDir)
If (Not F Is Nothing) Then
PickFolder = F.Items.Item.path
End If
Set F = Nothing
Set SA = Nothing
End Function
'***********************************************************************
Sub BrowseSource_OnClick()
Dim strStartDir
strStartDir = "c:\Programs"
TxtInputFolder.value = PickFolder(strStartDir)
End Sub
'***********************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'***********************************************************************
</SCRIPT>
<body>
Select the source folder :
<input type = "text" Value="c:\hta\photos" name = "TxtInputFolder" size="40"/><br><br>
<input type = "button" value = "Browse for the source Folder" Name="BrowseSource"><br><br>
Width <input type="text" name="w" size="6" value="320"><br>
Height <input type="text" name="h" size="6" value="240"><br><br>
<input type="submit" name="" value="Resize my photos" onClick="ResizePhotos">
</body>