Ask a Question

WshShell "The system cannot find the file specified"

SOLVED
bschwass
Occasional Contributor

WshShell "The system cannot find the file specified"

Use of the WshShell in our test suite has suddenly stopped working and I cannot figure out why. 

I have written a simple test to hone in on the error:

function test() { //Don't check this in
    WshShell.Exec("dir")
}

 

Running this function pops up the error

bschwass_0-1598050157623.png

Shell is the name of the script I have written this function in. It definitely does exist at the path specified (though I find it strange there's no file extension in the error).

 

TestComplete is running as admin. This error seems to be happening no matter what the command is. 

To be totally honest, I don't fully understand how WshShell works. If there is something in the properties of the project that need to be setup in order for it to work there's a good chance that's been accidentally broken, but I can't find anything anywhere telling me what that setup is, so I can't check. 

 

Any help would be appreciated. 

 

5 REPLIES 5
sonya_m
SmartBear Alumni (Retired)

Thank you for creating this topic! @bschwass 

 

@anupamchampati , @BenoitB@Reshail @tristaanogre Any suggestions?🙂


Sonya Mihaljova
Community and Education Specialist

anupamchampati
Frequent Contributor

Just remove the " " from the dir, it is been treated as String because of that.

Just pass the dir as Para.
function test()
{
 WshShell.Exec(dir)
}

bschwass
Occasional Contributor

I believe treating it as a string is the point? WshShell.Exec is meant to execute a string as a command I believe. Removing the quotes give the error that dir is not defined. Defining dir as a variable string results in the original error. 

I thought you are passing some command from dir as para

Microsoft have provided article to run dir as WshShell command

Try with this and check whether you need this one

function test()
{
WshShell.Run("%comspec% /k dir",1,true)
}
https://devblogs.microsoft.com/scripting/how-can-i-call-the-dir-command/

 

 

sonya_m
SmartBear Alumni (Retired)

Thank you for helping Anupam!

 

@bschwass Have this approach worked for you?


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: