WshShell "The system cannot find the file specified"
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for creating this topic! @bschwass
@anupamchampati , @BenoitB, @Reshail @tristaanogre Any suggestions?🙂
Sonya Mihaljova
Community and Education Specialist
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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/
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for helping Anupam!
@bschwass Have this approach worked for you?
Sonya Mihaljova
Community and Education Specialist
