English 中文(简体)
执行两项职能,即:
原标题:executing two functions with wshshell
  • 时间:2010-03-25 06:42:38
  •  标签:
  • vbscript

i 履行两种不同职能(范围与齐p)。 能够用单张剪辑。 i 审判

Dim WshShell, oExec,g,h
h="D:d"

g="xcopy " & h & " " & "D:y /E & cmd /c cd D:c & D: & winzip32.exe -min -a D:a"
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec(g)

Do While oExec.Status = 0
     WScript.Sleep 100
Loop

WScript.Echo oExec.Status

it dint work.though separate programs i.e g="xcopy " & h & " " & "D:y /E" and g="cmd /c cd D:d & D: & winzip32.exe -min -a D:a" works. i am sorry for the formatting problem. any help is appreciated.

最佳回答

我不认为你可以这样做:经营者是指挥线的载体的一部分,而不是制造厂或壳牌照。

我看到这方面工作的若干途径:

  1. call CMD.exe and pass your command-line as parameter. (i.e. "%ComSpec% /c " & Stuff)
  2. Write a batch on the fly and execute it.
  3. Just write two calls to WshShell.Exec instead of one. It s probably better since you can check the result of each individual part of the process anyway. You can even do the copy in script instead of calling xcopy for extra error checking and loging.

这里是一部关于如何复制双倍的样本代码,然后在VB文本中相互tz:

Dim WshShell, oExec, oFS, oF

szSourcePath="c:	mp	estfolderSrc"
szDestinationPath="c:	mp	estfolderDest"
szDestinationZip="c:	mpfinal.zip"
bOverwrite=true

  Create objects
Set oFS = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")

  cleanup target folder
if  oFS.FolderExists(szDestinationPath) then
  oFS.DeleteFolder szDestinationPath, true
end if
  Create target folder
set oF = oFS.CreateFolder(szDestinationPath)


  Copy content of the source folder to the target folder
oFS.CopyFolder szSourcePath & "*", szDestinationPath, bOverwrite

  delete old zip
if oFS.FileExists("c:myzip.zip") then
  oFS.deleteFile("c:myzip.zip")
end if

wshShell.CurrentDirectory = "c:	mp"   set current directory to this
Set oExec = WshShell.Exec("c:program fileswinzipwinzip32.exe -min -a c:myzip.zip" )
Do While oExec.Status = 0
  WScript.Sleep 100
Loop
问题回答

暂无回答




相关问题
What approach should I use to test a VBScript?

I ve been asked to help out with a project which has made extensive use of VBScript to process a whole bunch of text files and generate certain outputs - sanitized files, SQL entries etc.. The script ...

Unable to call c# code from vbscript - ActiveX error

I am trying to call a method I have written in C# from VBScript. I have followed just about all of the instructions I can find on the web and am still having problems. Specifically I am getting Error:...

How to set delay in vbscript

How to set delay in vbscript? WScript.Sleep(100) does not work on Windows XP, Vista.

Using Classes in a Dictionary in Classic ASP

I usually do C# but have inherited a classic ASP project. I have defined a class: Class clsPayment Public Name End Class Set objPayment = New clsPayment objPayment.Name = "...

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

Problem casting field when querying spreadsheet

I am trying to query an .xls spreadsheet with VBScript, but I have run into an issue when trying to cast a field. I connect to the spreadsheet like this. Set objConnection = CreateObject("ADODB....

热门标签