How do I run a Script?
-
14. března 2012 10:08
Hi All,
I want to use the below code from this useful technet link about creating shortcuts on all users desktops (http://social.technet.microsoft.com/Forums/en/ITCG/thread/c00f6266-e7b4-414b-90ca-5def6d83ce44)
On Error Resume Next
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
logonserver = wshShell.ExpandEnvironmentStrings("%logonserver%")
folderSpec = wshShell.ExpandEnvironmentStrings("%allusersprofile%")
fileName = "file.doc.lnk"
If Not objFSO.FileExists(folderSpec & "\Desktop\" & fileName) Then
objFSO.CopyFile logonServer & "\Netlogon\" & fileName, folderSpec & "\Desktop\" & fileName
End If
On Error Goto 0I've put the file in the netlogon share and now I do not know how to run this script. Is it a .bat or .vbs file? And how would I put this script on everyone's PC on the domain?
Kind Regards
Anthony Wells
Všechny reakce
-
14. března 2012 10:55
it's a vbs
personnaly, i have a bat file, that launch the script using cscript.exe
then i put the bat inside a GPO (find logon script parameter). The gpo must be linked to the OU where your users are.
-
14. března 2012 11:02It is a VB Script file. All you need to do is to save it as something.vbs in the netlogon share. There is no need to put the script on everyone's PC. Note also that you are likely to run into UAC issues when running the script on Windows 7 machines.
- Upravený OberwaldMicrosoft Community Contributor 14. března 2012 11:05
-
14. března 2012 12:53
Indeed I would create a batch file that you list in the user profile which has a line similar to this:
cscript //t:20 //b //nologo %0\..\logonlog.vbs
//t:20 This command automatically closes your script after 20 seconds, this is useful if you script is prone to becoming unresponsive.
//b Batch mode, supresses errors and prompts
//nologo Supress the Cscript version number at the start of the command
%0\\..\ refers to the \netlogon share
- Označen jako odpověď Wellseytkd 14. března 2012 16:39
-
14. března 2012 13:46
Hi All,
Thanks for the useful advise and information. Do you know of any batch file code that could copy a shortcut/file from a share location to users desktops in both windows 7 and XP?
-
14. března 2012 13:58
Just to update you all,
I have found the below code:
echo [InternetShortcut] >"%userprofile%\desktop\google.url"
echo URL=http://www.google.com/ >>"%userprofile%\desktop\google.url"
echo IconFile=e:\Backups\google.ico >>"%userprofile%\desktop\google.url"
echo IconIndex=0 >>"%userprofile%\desktop\google.url"I've tried it and it works perfectly. However it doesnt display the favicon from google. Any idea what I need to do?
- Označen jako odpověď Wellseytkd 14. března 2012 16:39
-
14. března 2012 15:06Moderátor
This works for me (with the icon), so I am forced to surmise that the mapped location of the icon, e:\backups, is not available or the icon file is not there in your situation. Is the drive properly mapped and does the user have read permission on that share folder? It might be more robust to copy the icon to a 'writeable' location on the local drive (%appdata%, maybe).
Tom Lavedas
- Upravený Tom LavedasModerator 14. března 2012 15:06 typo
- Označen jako odpověď Wellseytkd 14. března 2012 16:39