1

I am trying to launch "GetPID.exe" and store the error code. This is the .vbs code :

Set WshShell = CreateObject("WScript.Shell")

strPath = Wscript.ScriptFullName

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
strFolder = strFolder & "\GetPID.exe"
Msgbox strFolder 
Dim temppid
temppid = WshShell.Run(strFolder , 0 , True)

However, at the last line, I get the following message:

G:\test001.vbs(11, 1) (null): No application is associated with the specified file for this operation.

The MsgBox echoes the correct path to the exe, so I am confused why is there the error.

loadingnow
  • 597
  • 3
  • 20

1 Answers1

0

Avoid answering questions in comments? I agree myself but this thesis seems to be considered opinion-based here.
However, I agree yet another (outweighing) topical sentence: a guess (a hunch) is not an answer. In other words, I like generally applicable, well-explained solutions in well-sourced answers.

Unfortunately, due to lacking information on GetPID.exe, I can neither explain nor source this forced answer: as a matter of general principle, enclose the first parameter of Run method in a pair of double quotes.

You could use next syntax:

temppid = WshShell.Run( """" & strFolder & """", 0 , True)
Community
  • 1
  • 1
JosefZ
  • 28,460
  • 5
  • 44
  • 83
  • not a forced answer, at least the question is not unanswered (: but a guess was answering the the question... what to do?... delete question? edit question? delete answer? edit answer? – loadingnow Nov 05 '16 at 16:50
  • its better if the answer is not forced: "avoid answering questions in comments" was only my opinion... so sorry... – loadingnow Nov 05 '16 at 16:54
  • @loadingnow you can give your own answer explaining origin of error; then, consider marking most helpful one as accepted. [See this page](http://meta.stackexchange.com/questions/5234/) for an explanation of why this is important. I can delete my forced one on your demand. – JosefZ Nov 05 '16 at 17:06