WshShell.Exec: The system cannot find the file specified.

Posted on 2009-05-08
Last Modified: 2012-05-06
I'm a running a script to apply permissions to a folder. I've added the location to xcacls.exe in system path, played around with the syntax and I always get the following error: WshShell.Exec: The system cannot find the file specified.

I've echoed the variables. Below is the output from primal script:

strUserID: dduck
strHomeDir: \\acs01\users\PAstu\2011\dduck
Setting Permissions For dduck on \\acs01\users\PAstu\2011\dduck

G:\IS_NTS_Shared\NetAdmin\Scripts\Account_Automation\School\PA\Permissions.vbs(102, 1) WshShell.Exec: The system cannot find the file specified.

Below is the function.

Function setAdmin()
wscript.Echo strUserID
wscript.Echo strHomeDir
wscript.echo("Setting Permissions For " & strUserID & " on " & strHomeDir)
Set objShell = CreateObject("WScript.Shell")
objShell.Exec "xcacls.exe " & strHomeDir & " /G builtin\administrators:F /y" 
wscript.echo("Administrator Permissions granted")
End Function

Open in new window

Question by:JB4375
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Accepted Solution

abhimail2002 earned 250 total points
ID: 24337465
Try Doing this instead of Set objShell = CreateObject("WScript.Shell")

$objShell = CreateObject("WScript.Shell")
if @error
 ? @error " - " @serror ?
 get $
LVL 14

Assisted Solution

rejoinder earned 250 total points
ID: 24337581
Try adding extra quotes around the strHomeDir variable...
objShell.Exec "xcacls.exe """ & strHomeDir & """ /G builtin\administrators:F /y"

Author Comment

ID: 24337862
@abhimail2002: Errors on this line: $objShell = CreateObject("WScript.Shell")
G:\IS_NTS_Shared\NetAdmin\Scripts\Account_Automation\School\PA\Permissions.vbs(103, 1) Microsoft VBScript compilation error: Invalid character
@rejoinder: I added the quotes and got the same error.
LVL 14

Expert Comment

ID: 24338175
If you execute the command manually, does it work?

Author Comment

ID: 24338190
OK, I figured out the that the path to xcacls.exe was off. So much that. Points awarded to both for timely response. Thanks guys

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question