Solved

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

Posted on 2009-05-08
5
6,048 Views
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.

Thanks
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

0
Comment
Question by:JB4375
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
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 $
endif
$objShell.Exec($ShellCMD)
0
 
LVL 14

Assisted Solution

by:rejoinder
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"
0
 
LVL 1

Author Comment

by:JB4375
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.
0
 
LVL 14

Expert Comment

by:rejoinder
ID: 24338175
If you execute the command manually, does it work?
0
 
LVL 1

Author Comment

by:JB4375
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
0

Join & Write a Comment

Installing a printer using group policy preferences is not that hard let’s take a look at it. First lets open up your group policy console and edit the policy you want to add it to. I recommend creating a new policy for each printer makes it a l…
Introduction You may have a need to setup a group of users to allow local administrative access on workstations.  In a domain environment this can easily be achieved with Restricted Groups and Group Policies. This article will demonstrate how to…
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 configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now