On Thu, Jan 22, 2009 at 7:19 PM, Jim Majorowicz <[email protected]> wrote:
> When I run it, I get the Input box okay, but as soon as I click okay after
> typing in some text, I get a quick dos pop up but nothing appears…
As a first guess, I'd say maybe the current working directory isn't
what you think it is when WshShell.Run is called, so the folders
aren't where XCOPY looks for them. Try prefixing the full path to the
folder names.
Some additional tips:
1. Tell WshShell.Run to wait for the command to complete, rather than
continuing immediately.
2. Have the script display what the command is before it executes
3. Use symbolic constants instead of CHR()
4. Use line continuation to make long lines easier to understand
The following is partial code:
' funny characters
Const sp = " " ' space
Const bs = "\" ' backslash
Const dq ="""" ' double-quote
' folder containing everything
Const basepath = "N:\foo\bar"
' runs a command, waits for exit
Sub RunWait (cmd)
Const WshShellRunHidden = 0
Const WshShellRunWait = True
WshShell.Run cmd, WshShellRunHidden, WshShellRunWait
End Sub
' put your user dialog stuff here
' prefix full paths
templatefolder = basepath & bs & templatefolder
foldername = basepath & bs & foldername
' build command
executeCMD = _
XCopyCMD & sp & _
dq & templatefolder & dq & sp & _
dq & foldername & dq & sp & _
XCopySWCH
' display, then execute
WScript.Echo "executeCMD = <" & executeCMD & ">"
RunWait executeCMD
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~