Script to remove options for local drive when user log's in on remote apps

Hi,
We have several customers that use our remote app’s on our servers however they keep saving items to the local disk instead of their network share. is there a script you have or can make to hide these drives from users except for z or y?

Would you not be better doing this via Group Policy ??

Would be but user level targeting is what I struggle with. If you got a good walk through I’ll give it a go.

Google it !! :wink: it’s very easy.

Yeah tried the google. that’s why i asked for a script.

Ill have a look tomorrow and point you in the direction. Group Policy is the definite way to go !! :wink:

@monster-it,
Hai we will analyze your request and get back with the script soon

Hi @monster-it

Here is the Script for your request, Please refer it.

  • This Script will not hide your Drives instead it will not allow permission to access, because hiding files causes all users to view blind.
  • Run this Script to Users whoever you don't want to access your Local Drives.

NOTE : Run as Administrator

</b>
import _winreg
import platform
import os
import ctypes
class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
    def __enter__(self):
        self.old_value = ctypes.c_long()
        self.success = self._disable(ctypes.byref(self.old_value))
    def __exit__(self, type, value, traceback):
        if self.success:
            self._revert(self.old_value)
l=[]
a=[]
l= platform.platform()

if l[9]=='0':
    k=l[:10]

else:
    k=l[:9]


if k=="Windows-7":
    a=platform.machine()
    if a[3:]=='64':
        s=a[3:]
        k=k+s


if(k=="Windows-7"):
    print k
    handle = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer",0,_winreg.KEY_ALL_ACCESS)
    _winreg.SetValueEx(handle, "NoViewOnDrive", 0, _winreg.REG_DWORD, 0x4)
    print "local drive will be secured"
    print 'Restarting the endpoint to apply changes ....'
    with disable_file_system_redirection():
        val=os.popen('shutdown -r').read()
else:
    print k
    handle = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer",0,_winreg.KEY_ALL_ACCESS)
    _winreg.SetValueEx(handle, "NoViewOnDrive", 0, _winreg.REG_DWORD, 0x4)
    print "local drive will be secured"
    print 'Restarting the endpoint to apply changes ....'

    with disable_file_system_redirection():
        val=os.popen('shutdown -r').read()


<b>

20171009-Drive_permission.json (2.33 KB)