adrian
adrian

Reputation: 286

Windows script host - There is no file extension in (file path)

I am trying to run a windows script using windows task scheduler. I am getting the following error.

enter image description here

This is the full file path

C:\Users\Desktop\service calibration details\RunExcel\RunExcel.vbs

The above screen shot does not show the full filepath

What does this mean?

How can i perform this succesfully?

Upvotes: 3

Views: 17089

Answers (2)

Raikol Amaro
Raikol Amaro

Reputation: 449

The problem is caused by the spaces on your file path. I found the same problem using the function Shell on VBA and although the environment is not the same I think the solution is applicable. I will try to address your question on a general approach, not only for Windows Task Scheduler.

The above screen shot does not show the full filepath

What does this mean?

The screen doesn't show the full path because Windows will read the path as a single string of characters, therefore, it will stop reading when it finds the first space on your path, which is exactly after the word "service". At that point Windows believes your full path is "C:\Users\Desktop\service" so when it looks for the script in that location.........ERROR!!.

How can i perform this succesfully?

The way to solve this issue is enclosing the file path in quotation marks. The correct way to do it depends on the environment you are using. Try these starting in number 1.

  1. Use simple quotation marks to enclose the file path: "C:\Users\Desktop\service calibration details\RunExcel\RunExcel.vbs"

  2. If your file path is already a part of a string enclosed in quotation marks(for example an argument of a function) use double quotation marks or CHR(34). Following examples use the function Shell on VBA.

Using double quotation marks:

Shell "wscript ""C:\Users\Desktop\service calibration details\RunExcel\RunExcel.vbs""", vbNormalFocus

Using CHR(34):

Shell "wscript " & Chr(34) & "C:\Users\Desktop\service calibration details\RunExcel\RunExcel.vbs" & Chr(34), vbNormalFocus

Upvotes: 6

Stephen Correia
Stephen Correia

Reputation: 81

You could also rename the folder to no longer have spaces - perhaps use underscores instead.

C:\Users\Desktop\service_calibration_details\RunExcel\RunExcel.vbs

Upvotes: 2

Related Questions