Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Buuuut, AT.EXE (in Win2K) doesn't run as the currently-logged-in user. I know I can change that, but it doesn't appear to be programmatically changeable (and I don't want to go around to all of these machines).

But yes it is programmatically changeable. The following is a snippet of a hack I did...
#!/usr/bin/perl -w # Modules use strict; use Win32::API; # Variables use vars qw($host $user $password $success $OpenSCManager $LockService +Database); use vars qw($lock $OpenService $ChangeServiceConfig $SChandle $Shandle +); use vars qw($UnlockServiceDatabase $CloseServiceHandle); # Constants use constant SC_MANAGER_ALL_ACCESS => 0x000F0000|0x0001|0x0002 |0x0004|0x0008|0x0010|0x0020; use constant SERVICE_CHANGE_CONFIG => 0x0002; use constant SERVICE_NO_CHANGE => 0xffffffff; # Change theese... $host="SOME_COMPUTER"; $user=".\\local_user_account"; $password="password_for_user"; # Import stuff $OpenSCManager = new Win32::API( "advapi32", "OpenSCManager", ["P", "N", "N"], "I"); if (! defined $OpenSCManager) { die "Can't import OpenSCManager"; } $LockServiceDatabase = new Win32::API( "advapi32", "LockServiceDatabase", ["I"], "I"); if (! defined $LockServiceDatabase) { die "Can't import LockServiceDatabase"; } $OpenService = new Win32::API( "advapi32", "OpenService", ["I", "P", "N"], "I"); if (! defined $OpenService) { die "Can't import OpenService"; } $ChangeServiceConfig = new Win32::API( "advapi32", "ChangeServiceConfig", ["I", "N", "N", "N", "P", "P", "N", "P", "P", "P", "P"], "N"); if (! defined $ChangeServiceConfig) { die "Can't import ChangeServiceConfig"; } $UnlockServiceDatabase = new Win32::API( "advapi32", "UnlockServiceDatabase", ["I"], "I"); if (! defined $UnlockServiceDatabase) { die "Can't import UnlockServiceDatabase"; } $CloseServiceHandle = new Win32::API( "advapi32", "CloseServiceHandle", ["I"], "I"); if (! defined $CloseServiceHandle) { die "Can't import CloseServiceHandle"; } $SChandle=$OpenSCManager->Call( $host, 0, SC_MANAGER_ALL_ACCESS); die "Failed to open service manager on $host" unless $SChandle; $lock=$LockServiceDatabase->Call( $SChandle); die "Failed to lock service database on $host" unless $lock; $Shandle=$OpenService->Call( $SChandle, "Schedule", SERVICE_CHANGE_CONFIG); die "Failed to open Task Scheduler on $host" unless $Shandle; $success=$ChangeServiceConfig->Call( $Shandle, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, 0, 0, 0, 0, $user, $password, "Task Scheduler"); print "Change status: "; print $success?"OK\n":"Failed\n"; $UnlockServiceDatabase->Call( $lock); $CloseServiceHandle->Call( $SChandle);

/brother t0mas

In reply to RE: How long 'tween now and then? by t0mas
in thread How long 'tween now and then? by myocom

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (3)
    As of 2018-06-21 18:53 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (118 votes). Check out past polls.