Python Script as Scheduled Task

Discussion in 'Windows Server' started by Dave2014, Feb 8, 2014.

  1. Dave2014

    Dave2014 MDL Novice

    Feb 5, 2014
    4
    0
    0
    #1 Dave2014, Feb 8, 2014
    Last edited: Feb 8, 2014
    Hi all,
    I want to be able to run python scripts on my server that have an affect on the client computers attached to it's domain. Both my server virtual machine and my client virtual machine have Python installed. In the task scheduler I create a new task and browse to where my script is located, then I changed the user account in the task setup so the script will have an affect on the computer that a user is logged onto. I run the task but nothing happens on the client machine and the task status never changes from Ready to Running. Both machines can ping each other and the client is on the servers domain and both firewalls are disabled. However, when I change back the user account to Administrator so the script will have an effect on the server machine, the scripts runs and a dialog box appears with the results of the Python command in the script. Any help would be greatly appreciated. :) Thanks in advance!
     
  2. kelorgo

    kelorgo MDL Addicted

    Oct 29, 2012
    838
    1,499
    30
    You are confusing some things. When you say you want the script to "affect" the client computer, what do you mean exactly? Do you mean
    1) run the script on the server, but (remotely) perform operations on the client, over a network
    2) or run the script on the client

    When you set up a task on the server, the script will always run on the server. Changing the user account under which to run it doesn't make it run on a different computer. The script will simply run on the server with that user's credentials, or, if the user doesn't have the right priveleges, not run at all (as seems to be the situation in your case).
     
  3. Dave2014

    Dave2014 MDL Novice

    Feb 5, 2014
    4
    0
    0
    Well that does make a lot of sense! Thanks! :) Yeah I was confusing it a small bit. I want to run the script on the server but remotely perform operations on the client over the network. How would I go about doing that as I am at a dead end :)
     
  4. marti-n

    marti-n MDL Novice

    Mar 13, 2012
    5
    1
    0
    Well, for simple remote execution you could use PSSession, so you can connect with PowerShell to a remote Windows host.

    You could look here for some examples of this: (May not post links -.-) on bit dot ly, slash LVruU7

    To do this in powershell you could use some code to execute an powershell script from python, as I don't know if you can use only Python to do this :/