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

Posted on 2009-05-08
Medium Priority
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 1000 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 1000 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
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 steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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 to another domain controller. Log onto the new domain controller with a user account t…
Suggested Courses

771 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