Announcement

Collapse
No announcement yet.

Script Requests - Itarian team will write the scripts for you :) for FREE.

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • THANK YOU amcssit!! Your posts helped me cobble together a script that fully works on Windows 10 Pro. As you said, I had to make a batch file with the REG ADD commands, and that worked perfectly. It seems Windows doesn't like when a 3rd party program modifies those registry keys directly. I combined the portion of the script that the developers created (here) that downloads the image and puts it into a local folder, and the "execute the batch file" script that you posted. Here's what I have, it's probably not 100% code efficient (because it's pretty much copy-pasting parts of 2 different scripts), but it works well in my environment.

    Code:
    #To define a particular parameter, replace the 'parameterName' inside itsm.getParameter('parameterName') with that parameter's name
    import os
    import subprocess
    import urllib
    import ctypes
    
    fromURL=itsm.getParameter('BackgroundImageUrl') ## Here mention the download url in parameters
    
    Down_path=os.environ['PROGRAMDATA']
    fileName = fromURL.split('/')[-1]
    DownTo = os.path.join(Down_path, fileName)
    
    Folder_name=r"LockScreenBatch" # Give the new folder name
    Folder_Path=r"C:\Temp" # Provide Path for the New folder
    URL=r'https://drive.google.com/PUT_YOUR_DIRECT_DOWNLOAD_LINK_HERE' # Provide the direct download link for the BAT file
    File_name=r"TLS.bat" #Provide the Bat file name with extension
    directory=Folder_Path+"\\"+Folder_name
    
    def ecmd(command):
    import ctypes
    from subprocess import PIPE, Popen
    
    class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirect ion
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirecti on
    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)
    
    with disable_file_system_redirection():
    obj = Popen(command, shell = True, stdout = PIPE, stderr = PIPE)
    out, err = obj.communicate()
    ret=obj.returncode
    if ret==0:
    if out:
    return out.strip()
    else:
    return ret
    else:
    if err:
    return err.strip()
    else:
    return ret
    
    import ctypes
    class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirect ion
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirecti on
    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)
    
    import subprocess
    with disable_file_system_redirection():
    import urllib
    
    def downloadFile(DownTo, fromURL):
    try:
    with open(DownTo, 'wb') as f:
    f.write(urllib.urlopen(fromURL).read())
    if os.path.isfile(DownTo):
    return '{} - {}KB'.format(DownTo, os.path.getsize(DownTo)/1000)
    
    except:
    return 'Please Check URL or Download Path!'
    
    print downloadFile(DownTo, fromURL )
    
    if not os.path.exists(directory):
    os.makedirs(directory)
    
    class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirect ion
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirecti on
    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)
    
    def Download(src_path, URL,fp):
    import urllib2
    
    request = urllib2.Request(URL, headers={'User-Agent' : "Magic Browser"})
    try:
    gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
    parsed = urllib2.urlopen(request,context=gcontext)
    except:
    parsed = urllib2.urlopen(request)
    if not os.path.exists(src_path):
    os.makedirs(src_path)
    with open(fp, 'wb') as f:
    while True:
    chunk=parsed.read(100*1000*1000)
    if chunk:
    f.write(chunk)
    else:
    break
    return fp
    
    def bat(path):
    print path
    with disable_file_system_redirection():
    print "Excuting Bat File"
    process = subprocess.Popen([path],stdout=subprocess.PIPE)
    stdout = process.communicate()[0]
    print "---------------------------"
    print stdout
    
    if __name__=='__main__':
    import time
    fp = os.path.join(directory, File_name)
    path=Download(directory, URL,fp)
    print path
    time.sleep(10)
    bat(path)
    And the .bat file simply contains the 4 REG ADD commands from the previous couple posts pointing at the image path that is created by the first half of the script.


    Thank you everyone who helped!

    Edit: If someone would like to use this for themselves, I believe you will need to:
    • Change the image URL in the parameters
    • Change/create the .bat file to point at the correct image path
    • Upload the .bat file to your Google Drive (or other filehost)
    • Change the URL for the download in the script
    • Change the filename of the .bat file in the script
    Last edited by day-it-an; 07-28-2020, 10:32 PM.

    Comment


    • Hi day-it-an,

      Thanks for you so much for your input amcssit.

      Our script developers prepared this script, please try and provide your feedback
      https://scripts.itarian.com/frontend...ckground-image

      Kind Regards,
      PremJK

      Comment


      • Good job day-it-an !!

        Comment


        • Hi, PremJkumar , what possibilities exist to create a script that allows me to block the option of making printscreen on the endpoints, so that users cannot take screenshots from the Windows keyboard?
          Last edited by ezuleta; 07-29-2020, 07:39 PM.

          Comment


          • Hi ezuleta,

            Thanks for your script request. We have asked our script developers to check and provide feedback.

            Kind Regards,
            PremJK

            Comment


            • Hi ezuleta,

              Please try this script prepared by our script developers to suffice your needs
              https://scripts.itarian.com/frontend...n-on-endpoints

              Kind Regards,
              PremJK

              Comment


              • PremJkumar hi, the script worked perfectly, my requirement now is to rollback this script in order to normalize the use of Windows PrintScreen.

                Comment


                • Hi ezuleta,

                  Thanks for providing feedback. We have asked our script developers to provide script to rollback.

                  Kind Regards,
                  PremJK

                  Comment


                  • HI ezuleta,

                    Please find scripts to enable and disable print screen option in endpoints

                    Disable Print Screen
                    https://scripts.itarian.com/frontend...n-on-endpoints

                    Enable Print Screen
                    https://scripts.itarian.com/frontend...n-on-endpoints

                    Kind Regards,
                    PremJK

                    Comment


                    • Hi, PremJkumar

                      Thank you very much for the contribution. Scripts work great.

                      Comment


                      • Looking for a script the produces a list of windows patches installed, puts the list of the installed patches on local drive, and emails the list out.

                        Comment


                        • Hi nsmedley,

                          Thanks for your script request. We have asked our script developers to check and provide feedback whether script is possible or not.

                          Kind Regards,
                          PremJK

                          Comment


                          • Hi nsmedley,

                            Please try this script prepared by our script developers and provide feedback
                            https://scripts.itarian.com/frontend...il-output-file

                            Kind Regards,
                            PremJK

                            Comment


                            • nsmedley
                              nsmedley commented
                              Editing a comment
                              Thank you the scripts works but no email is coming thru.. including the log part.. tried both business and personal email accounts.. ANy ideas the issue.

                          • I would like to be able to have a script run only after checking that the endpoint attempting to run the script can reach the remote system. For example, I have a script to install some software but I want to be able to validate that the system that the script is running on can reach the 10.0.0.254 IP Address before attempting to install. Is that possible? In theory, if I want to push out a scripted install to all of my machines, I would want to be able to only have the machines that can reach the shared software repository to run the installer. I would not want to have the machines that are off network be able to run the script. Additionally, maybe email which machines were successfully able to be processed and ones that were offline or remote? Thanks.

                            Comment


                            • Hi balldigy,

                              Thanks for your request. We have asked our script developers to check and provide feedback.

                              Kind Regards,
                              PremJK

                              Comment

                              Working...
                              X