Windows Script Host

A

antoni

Would anyone know why this sample code does not work
properly under XP. It seems that the spaces in the path
name are not interpreted correctly.
I need to use the full path because I have two versions of
Office on my computer.

Thanks for any suggestion.
**************************************************
<job id="Test">
<script language="Vbscript">

dim WshShell, AcPath
dim Return

'The following gives a file not found
'AcPath = "C:\Program files\Microsoft office\office\"

'The following displays the folder content
AcPath = """C:\Program files\Microsoft office\office\"""

'The following opens the default version of Access
'AcPath = ""

msgbox AcPath

set WshShell = Wscript.CreateObject("WScript.Shell")

Return = WshShell.run (AcPath & "msaccess.exe",1,true)


MSGBOX "The End"

</script>
</job>
 
D

David Jones

Use the following:

'Since you're adding stuff, you only want the beginning
quote.
AcPath = """C:\Program files\Microsoft office\office\"
'Append the filename you want so you have it all in one
variable, rather than messing around with the command line
'Since this is the end of the real path, quote the end
AcPath = AcPath + "msaccess.exe"""
set WshShell = Wscript.CreateObject("WScript.Shell")
Return = WshShell.Run (AcPath,1,true)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top