Solved

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

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

785 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