Copy file to Domain user desktop by using Group Policy

Copy file to Domain user Desktop using .vbs script from Group Policy

Option Explicit

Dim objNetwork
Dim objFSO, objFileCopy, objGuyFile
Dim strFilePath, strDestination, strUserName
Set objNetwork = WScript.CreateObject(“WScript.Network”)
‘ Here is where we extract the UserName
strUserName = objNetwork.UserName
strFilePath = “\\servername\Desktop\BACK.bat
strDestination =”C:\Documents and Settings\” & strUserName & “\Desktop\”

Set objFSO = CreateObject(“Scripting.FileSystemObject”)

Set objFileCopy = objFSO.GetFile(strFilePath)
‘ Copy the file to its destination
objFileCopy.Copy (strDestination)
‘WSCript.Echo “Copied to ” & strDestination
Wscript.Quit

Advertisements

Restriction to Open Software Maximun Sessions

Below is .vbs script for restrict users to open software maximun 2 sessions

Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = “.”
 
Set oReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & _
    strComputer & “\root\default:StdRegProv”)
 
strKeyPath = “Software\Attachmate\KEA\4.23\KEAVT”
strValueName = “MaxSessions”
dwValue = 2
oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue

netuse.bat and Map.vbs (Create Map Drive from Group Policy)

create map drive for domain user from Group policy .bat

net use L: \\Servername\share

create map drive for domain user from Group policy .vbs

Option Explicit

Dim strDriveLetter, strRemotePath, strUserName
Dim objNetwork, objShell
Dim CheckDrive, AlreadyConnected, intDrive
strDriveLetter = “H:”
strRemotePath = “\\servername”
Set objShell = CreateObject(“WScript.Shell”)
Set objNetwork = CreateObject(“WScript.Network”)
Set CheckDrive = objNetwork.EnumNetworkDrives()
On Error Resume Next
AlreadyConnected = False
For intDrive = 0 To CheckDrive.Count – 1 Step 2
 If CheckDrive.Item(intDrive) =strDriveLetter _
 Then AlreadyConnected =True
Next
If AlreadyConnected = False then
 strUserName = objNetwork.UserName
 objNetwork.MapNetworkDrive strDriveLetter, strRemotePath _
 & “\” & strUserName
End if

WScript.Quit