Sign in to follow this  
Followers 0
Zizzzzy

Running a program without logging in

1 post in this topic

Hey Guys,

My last stop to these forums was to gain some help getting my STD I/O working correctly..... that thread can be found here http://www.autoitscript.com/forum/index.php?showtopic=35176

Now that my program is complete, my problems conitnue, only in the sence that it doesnt work right :whistle:

Basic concept of the program: Since delprof (utility for removing profiles) does not support a command line syntax to specify an account to delete, I need to record the output with Default no for all found profiles, query those results then run it again passing a yes or no based on the profile. logged in, it works like a charm, however running it as it will need to be, as system while not logged in seems to be causing errors. I do not read from STDErrread, perhaps I should. At a given time in the AM our machines turn on and run updates and such in the background. It is at this time my program will be executed. What seems to be happening is my process launches, and thats it. I log into the system later and there is still a box (that launched my program) open, my program is still running (process), and there is a box that I assume may be an error message which is not displayed correctly. It comes up as a transparent box, no letters, nothing to help me figure out what it is, however if I double click the icon in the upper left corner, the box vanishes and my program exits... however nothing happens in terms of results the program is to produce.

Questions. 1, is autoit limited and not able to do such task (ie dependant on GUI).. or

Question 2, do I not know what I am doing? lol (well obviously)

If there are minor changes that can be made or suggested error checking I can try please give me your thoughts, if this is a limitation to Autoit I am probably euchred and will need to rewrite this in another programing language.

Code:

#include <Constants.au3>
#include <array.au3>

Dim $Accounts
Dim $Counter = 0
Dim $_Input[50]

; Launches Delprof and enters (n)o for all found profiles, output directed to string
$CMD_PID = Run('"' & @WorkingDir & '\delprof.exe" /P', @WorkingDir, @SW_MINIMIZE, $STDIN_CHILD + $STDOUT_CHILD)
While ProcessExists($CMD_PID)
    StdinWrite($CMD_PID, "n" & @CRLF)
WEnd
    StdinWrite($CMD_PID)
    $Accounts = StdoutRead($CMD_PID,-1,1)
    ; Formating on the output string to capture the users and thier order.  Output to Array     
    $Accounts = StringStripWS($Accounts, 8)
    $Accounts = StringReplace($Accounts, "DeleteC:\DocumentsandSettings\", "")
    $Accounts = StringTrimRight($Accounts, 13)
    $Users = StringSplit($Accounts, "?(Yes/No/All)", 1)
_ArrayDisplay($Users, "users" )
DO
$Counter = $Counter + 1
; Cases for desired action on each entry in $Users
    Select
        Case $Users[$Counter]="Imager" or $Users[$Counter]="Administrator"
            ; Case for local Imager and Administrator accounts on local PC. Outputs N to preserve this account
            $_Input[$Counter - 1] = "n"
        Case $Users[$Counter]=""
            ; Case to ignore blank array entries in $Users
        Case Else
            ; Case to delete all other found accounts
            $_Input[$Counter - 1] = "y"
    EndSelect
Until $Counter = $Users[0]

_ArrayDisplay($_Input, "My new Array" )

; Launches Delprof and enters $Users values for all found profiles
$CMD_PID = Run('"' & @WorkingDir & '\delprof.exe" /P', @WorkingDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$Counter = 0
Do 
    StdinWrite($CMD_PID, $_Input[$Counter] & @CRLF)
    $Counter = $Counter + 1
Until $Counter = $Users[0] + 1
    StdinWrite($CMD_PID)

Regards,

Craig

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0