Script all users desktop windows 7




















I am now looking to see if it is possible to extend this to multiple users without hard coding paths since I don't happen to know which user might be using the computer at the time.

Since you don't want to hard code path's, we can use the FOR to search for. The script bellow will search each users desktop, remove all. A single minor mistake can end up in a disaster. The del command will be executed only if the cd command have successfully changed the current directory to MyFolder.

Now back to your original problem of extending your code to wipe out 'Desktops' of all other users of the PC. The first thing that should be considered is that a normal user typically does not have access to desktop folders of other users because of NTFS file system permissions which avoids non Administrators from accessing other users profile.

So the resulting script will have to run with administrative privileges. In fact the desktop directory of each user can defined to be located anywhere and placed in a folder other than Desktop. This is the case for other special folders other than Desktop. So the correct approach is to first retrieve a list of user profiles from registry and then for each user profile query the location of user's desktop.

Test Mode the default : In this mode it only shows the commands along with the path that it can delete but no actual deletion will be performed. But the definite location can be obtained from these registry keys:. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

What would be the best way tio achieve this? Can you delete this file on Desktop UI via delete button? Is you owner of this file? Does the file protected or used? Does the issue still persists if you run this BAT file as administrator? What I want to do is to run the batch script from the SCCM run the original program then run the batch script to delete desktop icon - with admin priileges - which did not work for me.

Office Office Exchange Server. Not an IT pro? System Center TechCenter. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related 1. Hot Network Questions. Question feed. Server Fault works best with JavaScript enabled.

Just remove that line from the script? I have near-zero experience scripting. I thought testing would just involve running that vbs on a local machine, and then putting it in a GPO if it worked properly. Tuesday, February 23, PM. Yeah - you're right it does, but I suggest that you run without the deletefile bit first, so that you can confirm that it is finding the correct shortcuts. Do this by:.

If if is finding the right shortcut then uncomment the DeleteFile objItem. Name bit and comment out the wscript. All rights reserved. Do you mean something like this? GetFolder WshShell. SpecialFolders "AllUsersDesktop". CreateShortcut File. Path If LCase Shortcut. DeleteFile File. The method is named poorly; it also allows you to open shortcuts and look at their properties, not just create shortcuts.

HTH, Bill. Can you show me the exact code you have now please? And the target path of the shortcut. Looks like it didn't find it so it may be your query is slightly out. DeleteFile sFile End If End Sub And to test it, I saved it to the desktop, opened a cmd, then cd'd to the desktop you saw above where I did that , and typed "cscript name.

The results are above. Because I'm still learning about code, I want to ask a few questions. Also, I was once told when using scripts for GPOs which I'm going to attach this script to , it shouldn't be a vbs file, but a.

Does this matter? Wednesday, February 24, PM. If all of your machines don't have PowerShell installed, then you can't use a PowerShell script. The script gets the collection of files in the "AllUsersDesktop" directory and iterates the collection.



0コメント

  • 1000 / 1000