Miscbrah Posted May 11, 2012 Posted May 11, 2012 Hi all (yet again.) I've come across a problem with this script I've knocked up which works for XP in copying desktop shortcuts, but not for Windows 7: sSource = "\\lhsdc1\netlogon\staffdesktop\*" set oWShell = createobject("Wscript.Shell") sDestination = oWShell.SpecialFolders("AllUsersDesktop") set oFSO = createobject("Scripting.FileSystemObject") oFSO.CopyFile sSource, sDestination, True I get a 800a0046 permission denied message on Windows 7. Not the best at scripting to be honest, and not sure how to go about making this work for 7 and XP together. I'm guessing some sort of variable based on OS? Is there some dodgy WMI-filtered alternative if using 7 and XP together? Would much rather have just the one script doing the business though, so if anyone can help me I'd be extremely grateful. Like, beer grateful.
themightymrp Posted May 11, 2012 Posted May 11, 2012 You might find that it is UAC on Windows 7 that is causing that problem. If you try copying and pasting things onto the Public\Desktop folder you will get a prompt to confirm you want to do this - sucks I know. Try disabling UAC and see if you script works, at least you will know you have the syntax correct. Then its a case of allowing it to run with Admin permissions 1
Miscbrah Posted May 11, 2012 Author Posted May 11, 2012 Hi! Thanks for getting back to me so quick! - no still getting those permission problems even with UAC off in GP. How do I run it with admin permissions btw?
themightymrp Posted May 11, 2012 Posted May 11, 2012 Not 100% sure but I think you can download a program called elevate32.exe (or elevate64.exe) from MS which you can call in a script. Have you considered using Group Policy Preferences to create the shorcut on the desktop? Or, if you do a bit of an "if exist" routine, you can set the destination to the all users desktop using this line: sDestination = "c:\users\public\desktop\"
themightymrp Posted May 11, 2012 Posted May 11, 2012 Try this: sSource = "\\lhsdc1\netlogon\staffdesktop\*" set oWShell = createobject("Wscript.Shell") Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists("c:\users\public\desktop") Then sDestination = "c:\users\public\desktop\" Else sDestination = "c:\documents and settings\all users\desktop\" End If set oFSO = createobject("Scripting.FileSystemObject") oFSO.CopyFile sSource, sDestination, True
Miscbrah Posted May 11, 2012 Author Posted May 11, 2012 (edited) Quick workaround I've got (just in case anyone from Google sees this) is by applying the same script as a machine startup policy, then applying WMI filters in GP for XP at logon time, then Win7 at startup. Clunky and stuff, but works. EDIT - gah missed that reply! Cheers, will give that a go Edited May 11, 2012 by Miscbrah 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now