Solved

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

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

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Joining two Windows domain into one subnet. 10 44
Question about Authentication Domain 6 68
Office 365 & Microsoft Azure 8 51
EXCHANGE, ACTIVE DIRECTORY 1 42
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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 …

919 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

16 Experts available now in Live!

Get 1:1 Help Now