Windows Script Host

  • Thread starter Thread starter antoni
  • Start date Start date
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>
 
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)
 
Back
Top