[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1476
  • Last Modified:

CopyFile Permission Denied on Logon Script

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
0
jad0083
Asked:
jad0083
  • 4
  • 3
1 Solution
 
RobSampsonCommented:
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

0
 
jad0083Author 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?
0
 
RobSampsonCommented:
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.
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
jad0083Author 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...
0
 
RobSampsonCommented:
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.
0
 
jad0083Author 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!
0
 
RobSampsonCommented:
Great! Thanks for the grade.

Regards,

Rob
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now