tags:

views:

206

answers:

1

i need to call two function on a single click event. and also the functions shud get executed sequentially. i tried click me . but its not working.its not calling any of the functions. here is the complete code. sorry for formatting.

<html>
<head>
<script type="text/vbscript">

function copy()
Dim WshShell, oExec,g,h
h="D:\d"

g="xcopy " & h & " " & "D:\y\ /E"
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec(g)

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

WScript.Echo oExec.Status
end function

function zip()
Dim WshShel, oExe
Set WshShel = CreateObject("WScript.Shell")

Set oExe = WshShel.Exec("cmd /c cd D:\d & D: & winzip32.exe -min -a D:\a")

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

WScript.Echo oExe.Status
end function

</script>
</head>


<body>
<button onclick="copy();zip();"> click me </button>
</body>

</html>

any help is appreciated.

A: 

Write a single function which calls copy and then zip. Wire that up to the onclick event.

David M
function both()call copy()call zip()end functionit only calls copy()
sushant
can u please tell the mistake i am making?
sushant
Are you sure copy() isn't erroring somewhere?
David M
yes copying is erroring. but copy is giving the output. for the line:wscript.sleep=100 it says- object required:'wscript'
sushant
can u plz help me out
sushant
Should that line not read: WshShell.Sleep 100?
David M
no i checked it. it does not work with wshshell.sleep.
sushant