We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

CopyFile Permission Denied on Logon Script

jad0083
jad0083 asked
on
Medium Priority
1,756 Views
Last Modified: 2012-05-06
Good Day Experts!
For the past few hours now, I've been trying to implement a filecopy of winexit.scr to networked computers through a login script on the GPO.  But for some reason, I always get a permission denied when the script executes on the actual computer.  I've tried 2 scripts already but both doesn't seem to work, any assistance would be very much appreciated.

'Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
'Set wshShell = Wscript.CreateObject("WScript.Shell")
'fileSrc="\\jad-server\Profiles$\winexit.scr"
'dest = "c:\windows\system32\"
'objFSO.CopyFile fileSrc, dest, true

'Dim objFS, SrceFldr, DestFldr
'SrceFldr =  "\\jad-server\Profiles$"
'DestFldr = "c:\windows\system32"
'Set objFS = CreateObject("Scripting.FileSystemObject")
'objFS.Copyfile SrceFldr & "\" & "Winexit.scr" , DestFldr
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Hi, you won't be able to do this as a Logon Script, unless your users have write access to the Windows\System32 folder, which is unlikely.

If you run the following as a StartUp script, and place your winext.scr file into the NetLogon share of your domain controllers, this should work, because StartUp scripts run under the local system account.

Regards,

Rob.
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
fileSrc="\\domain.com\NetLogon\winexit.scr"
dest = "c:\windows\system32\"
objFSO.CopyFile fileSrc, dest, true

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
@Rob
If by you mean a startup script, I also tried your approach, putting it in the startup under computer management/windows componenets/startup/, imported the vbs to the scripts folder and added it.  If that's the case, it still didn't copy the file.  Or do I need to actually physically copy to each and every computer under the domain?
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
No, it should work....so you've put the VBS file in the NetLogon share, did you also put the winext.scr file in the NetLogon share?  Do that, and make sure you change "domain.com" in the script to your domain suffix.  You should be able to use a command prompt to
ping domain.com

and get a response back from your closest domain controller.

Regards,

Rob.

Author

Commented:
This is on the script I placed on the netlogon share (opened netlogon and pasted vbs there as well as winexit.scr)
dim objFSO, fileSrc, dest
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
fileSrc="\\jad\NetLogon\winexit.scr"
dest = "c:\windows\system32\"
objFSO.CopyFile fileSrc, dest, true

for somereason it still doesn't copy the file as if the script doesn't execute?  Sorry for the late reply btw, was out of town...
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Have you applied it as a StartUp script (not a Logon script)?

You can try adding this to the code as well, just to see if it does run the script at all.

Set objFile = objFSO.CreateTextFile("C:\ScriptRun.txt", True)
objFile.Close

that will just create an empty "ScriptRun.txt" on the C Drive...

Regards,

Rob.

Author

Commented:
That did it, for some reason, the script wasn't executing on the client computers, redid the gpo and updated then it worked, thanks!
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Great! Thanks for the grade.

Regards,

Rob
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.