sublimnl Posted March 24, 2014 Share Posted March 24, 2014 Can anyone say why this script exits immediately in SciTE? Its strange, SciTE reports that the script has finished even though its still running in the background. As a result, I am not getting output written to the SciTE console and my for loop at line 20 is only executed once. SciTE actually reports that the script has finished executing before my test MsgBox on line 11! Here's the code: expandcollapse popup#include <File.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #RequireAdmin MsgBox(4096,"","test") Global $servers[1] Global $arrMA[1] $CommServes = "cs1,cs2" $CommServes = StringSplit($CommServes,",") $CommServes = _ArrayUnique($CommServes,1,1) _ArrayDelete($CommServes,0) $strPassword = InputBox("Enter Password","Enter Password for user","","•",200,135) For $cs in $CommServes CSConnect() Next Exit Func CSConnect() ConsoleWrite(@CRLF & "Connecting to " & $cs) RunWait(@ComSpec & " /c qlogin -cs " & $cs & " -csn " & $cs & " -u admin -clp " & $strPassword & "|clip", @WindowsDir, @SW_HIDE, $STDOUT_CHILD) $result = ClipGet() ConsoleWrite(@CRLF & ClipGet()) If StringInStr($result,"Error") > 0 Then MsgBox(4096,"Logon Error","Error during logon attempt. Exiting" & @CRLF & @CRLF & $result) Exit Else RunWait(@ComSpec & " /c qlist mediaagent -cs " & $cs & "|clip", @WindowsDir, @SW_HIDE, $STDOUT_CHILD) $qlist = ClipGet() $qlist = StringStripWS(StringReplace($qlist,@CRLF,","),$STR_STRIPALL) If StringRight($qlist,1) = "," Then $qlist = StringTrimRight($qlist,1) $qlist = StringSplit($qlist,",") _ArrayDelete($qlist,0) _ArraySort($qlist) _ArrayUnique($qlist) $qlist = _ArrayToString($qlist,",") ScanThem($qlist) ConsoleWrite(@CRLF & "Disconnecting from " & $cs) RunWait(@ComSpec & " /c qlogout -cs " & $cs & "|clip", @WindowsDir, @SW_HIDE, $STDOUT_CHILD) ConsoleWrite(@CRLF & ClipGet()) EndIf EndFunc Func ScanThem($ma) $strComputer = $ma $PS = Run("powershell.exe get-wmiobject -computer " & $strComputer & " win32_volume | where-object {$_.driveletter -eq $null -and $_.caption -NotLike '\\?\Volume*'} | select ""@{Name='Date';Expression={$((Get-Date).ToString('MM-dd-yyyy'))}},@{Name='Media Agent';Expression={$_.systemname}},@{Name='Mount Path';Expression={$_.Caption}},@{Name='Capacity (GB)';expression={[math]::round(($_.Capacity/ 1073741824),2)}},@{Name='FreeSpace (GB)';expression={[math]::round(($_.FreeSpace/ 1073741824),2)}}""|Export-CSV C:\export.csv -notype -append",@SystemDir, @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($PS) $result = StdoutRead($PS) ConsoleWrite($result) EndFunc Link to comment Share on other sites More sharing options...
Solution FireFox Posted March 24, 2014 Solution Share Posted March 24, 2014 The #RequireAdmin function forces the script to run as administrator. Since your SciTE is not run as admin it can't execute your script with admin privileges, so it won't be the owner of your process. Br, FireFox. Link to comment Share on other sites More sharing options...
JohnOne Posted March 24, 2014 Share Posted March 24, 2014 #RequireAdmin spawns a new process. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sublimnl Posted March 24, 2014 Author Share Posted March 24, 2014 Thanks guys. That was correct. I am not sure what happened, but I had the same SciTE process open all weekend and suddenly it started doing that this morning (between edits actually) despite the fact that #RequireAdmin was there all along. Sure enough, re-launching SciTE as an elevated process got it working once again. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now