Jump to content

command line wont run in server 2008 R2


lhk69
 Share

Recommended Posts

Any idea why this wont work??

#include <Process.au3>

Run("c:\windows\system32\dirquota quota list >> g:\quotareports\err.txt 2>&1", "c:\windows\system32")

_RunDos("c:\windows\system32\dirquota quota list >> g:\quotareports\err.txt 2>&1")

Neither will work. Runs fine from command prompt. But when I try to code it, it cant seem to find the path to the executable.

Ive also tried "shellexecute"

keeps returning.......

'c:\windows\system32\dirquota' is not recognized as an internal or external command,

operable program or batch file.

Runs fine on Windows 2003 R2

Yes, the exe is there.

Thanks in advance.

Link to comment
Share on other sites

Nobody? Anybody??

I have never had an issue where I cannot get a command line function to run in the background. Is it specific to server2008?

This works on server2003.

ANY suggestions?? Help. Im stuck.

I cant think of anything else to try. :)

Here is the WHOLE code......

; ******************************************************************************************
; *
; *   Purpose: Do FSRM functions.
; *
; * Developed by: Lee
; *
; *
; *
; *
; * Requirements:
; *
; *
; ******************************************************************************************
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <constants.au3>
#include <Process.au3>
#include <File.au3>
#include <array.au3>
#include <String.au3>
#include <Date.au3>
#include <Excel.au3>
;****************** Defins variables ***********************
Global $FileArray_1, $FileArray_2, $Auto_Quota_Array,  $Quota_Array, $OutputLine, $textStageDate[1], $OutArray[16], $remote
Global $OutPut_Dir = "G:"
Global $mod_date = _NowDate()
Global $prog_ver = FileGetVersion("G:quota2.exe")
Global $ProgName = " - Quota Utilities"
Global $Quota_Dat_File = $OutPut_Dir & "quotas.dat"
Global $Auto_Dat_File = $OutPut_Dir & "auto_quotas.dat"
Global $Quota_File = $OutPut_Dir & "quotas.txt"
Global $Personal_Quota_File = $OutPut_Dir & "Personal quotas.txt"
Global $Teams_Quota_File = $OutPut_Dir & "Teams quotas.txt"
Global $Auto_Quota_File = $OutPut_Dir & "auto_quotas.txt"
Global $ErrorFile = $OutPut_Dir & "Results.txt"
Global $85_config_File = $OutPut_Dir & "config_file_85.txt"
Global $100_config_File = $OutPut_Dir & "config_file_100.txt"

;*********************** Check for psexec, if not, create a new one ***********
If Not FileExists($OutPut_Dir & "psexec.exe") Then FileInstall("C:UsersmeDocumentsCode & ScriptsFSRM Migratepsexec.exe", $OutPut_Dir & "psexec.exe")

If FileExists($ErrorFile) Then
FileDelete($ErrorFile)
EndIf
Go_Main_Gui()

;*************************   Defined FUNCTIONS    ******************************************************************************
Func Go_Main_Gui()
;Build Main GUI
$Main_Form1 = GUICreate($ProgName, 300, 500, -1, -1)
;Create menu items
$filemenu = GUICtrlCreateMenu("File")
$filemenu_file = GUICtrlCreateMenuItem("File", $filemenu)
$filemenu_exit = GUICtrlCreateMenuItem("Exit", $filemenu)
$toolsmenu = GUICtrlCreateMenu("Tools")
$filemenu_parse = GUICtrlCreateMenuItem("Parse DAT files", $toolsmenu)
$helpmenu = GUICtrlCreateMenu("Help")
$helpmenu_contents = GUICtrlCreateMenuItem("Contents", $helpmenu)
$helpmenu_about = GUICtrlCreateMenuItem("About", $helpmenu)
;Create button controls
$get_button = GUICtrlCreateButton("Get FSRM Quota Data from SA2." , 20, 15, 265, 50, $BS_MULTILINE)
$import_button = GUICtrlCreateButton("Import FSRM Quota Data to SA3.", 20, 75, 265, 50, $BS_MULTILINE)
$spread_button = GUICtrlCreateButton("Process Spreadsheet", 20, 135, 265, 50, $BS_MULTILINE)
$hard_button = GUICtrlCreateButton("Convert all current from SOFT to HARD.", 20, 255, 265, 50, $BS_MULTILINE)
$change_button = GUICtrlCreateButton("ADD or MODIFY quotas.", 20, 315, 265, 50, $BS_MULTILINE)
$exit_button = GUICtrlCreateButton("Exit", 20, 420, 265, 50, 0)
;Display the GUI
GUISetState()
;Wait for an action from the GUI
While 1
  $v_selection = GUIGetMsg()
  Select
   Case $v_selection = $GUI_EVENT_CLOSE Or $v_selection = $filemenu_exit Or $v_selection = $exit_button
    Done_Check()
   Case $v_selection = $filemenu_file
    GUIDelete()
    Go_Main_Gui()
   Case $v_selection = $filemenu_parse
    GUIDelete()
    If FileExists($Quota_File) Then FileDelete($Quota_File)
    If FileExists($Auto_Quota_File) Then FileDelete($Auto_Quota_File)
    If Not _FileReadToArray($Quota_Dat_File, $FileArray_1) Then
     MsgBox(0, "Error", "Unable to open Quota Input Report file." & @CRLF & @CRLF & "Please run a new report.")
     Go_Main_Gui()
    EndIf
    If Not _FileReadToArray($Auto_Dat_File, $FileArray_2) Then
     MsgBox(0, "Error", "Unable to open Quota AUTO Input Report file." & @CRLF & @CRLF & "Please run a new report.")
     Go_Main_Gui()
    EndIf
    Parse_Quota()
    Parse_Auto()
    Go_Main_Gui()
   Case $v_selection = $spread_button
    GUIDelete()

    if FileExists( $Personal_Quota_File) then FileDelete( $Personal_Quota_File )
    if FileExists( $Teams_Quota_File) then FileDelete( $Teams_Quota_File )
    $vSpreadsheet = FileOpenDialog("Select the Quota spreadsheet", @DesktopDir & "", "Excel (*.xls;*.xlsx)", 1,"Quota Analyzer.xlsx")
    $oExcel = _ExcelBookOpen($vSpreadsheet,0,True)
    If @error = 1 Then
     MsgBox(0, "Error!", "Unable to Create the Excel Object")
     Exit
    ElseIf @error = 2 Then
     MsgBox(0, "Error!", "File does not exist - Shame on you!")
     Exit
    EndIf
    ; DO Personal
    $current_sheet = _ExcelSheetActivate($oExcel, "Personal" )
    ; Determint last USED row
    For $row = 12 to 1000
     $mt = _ExcelReadCell( $oExcel, $row, 1 )
     If $mt = "" Then
      $lastrow = $row
      $lastrow = $lastrow -12
      ExitLoop
     EndIf
    Next
    $aArrayExcel = _ExcelReadSheetToArray($oExcel,12,1,$lastrow,6)
     ; _ArrayDisplay($aArrayExcel, "Debug")
    ProgressOn("Please wait", "Processing PERSONAL worksheet.......", "0 percent")
    For $LineNumber = 1 To $lastrow
     $i = Round(($LineNumber / $lastrow ) * 100, 0)
     ProgressSet($i, $i & " percent")
     $vArray_Output =  $aArrayExcel[$LineNumber][1] & "," & $aArrayExcel[$LineNumber][6]
     FileWriteLine($Personal_Quota_File,$vArray_Output)
     If $LineNumber = $lastrow Then
      ProgressSet(100, "Done", "Complete")
      Sleep(500)
      ProgressOff()
     EndIf
    Next

    ; DO teams
    $current_sheet = _ExcelSheetActivate($oExcel, "Teams" )
    ; Determint last USED row
    For $row = 1 to 1000
     $mt = _ExcelReadCell( $oExcel, $row, 1 )
     If $mt = "" Then
      $lastrow = $row
      $lastrow = $lastrow - 2
      ExitLoop
     EndIf
    Next
    $aArrayExcel = _ExcelReadSheetToArray($oExcel,2,1,$lastrow,6)
    ; _ArrayDisplay($aArrayExcel, "Debug")
    ProgressOn("Please wait", "Processing Teams worksheet.......", "0 percent")
    For $LineNumber = 1 To $lastrow
     $i = Round(($LineNumber / $lastrow ) * 100, 0)
     ProgressSet($i, $i & " percent")
     $vArray_Output =  $aArrayExcel[$LineNumber][1] & "," & $aArrayExcel[$LineNumber][5] & "," & $aArrayExcel[$LineNumber][6]
     FileWriteLine($Teams_Quota_File,$vArray_Output)
     If $LineNumber = $lastrow Then
      ProgressSet(100, "Done", "Complete")
      Sleep(500)
      ProgressOff()
     EndIf
    Next
    _ExcelBookClose($oExcel)
    ; Create the quota.txt file
    Fileopen( $Quota_File , 2 )
    $file1 = FileRead ( $Personal_Quota_File )
    $file2 = FileRead ( $Teams_Quota_File )
    FileWrite( $Quota_File, $File1 )
    FileWrite( $Quota_File, $File2 )
    FileClose ( $Quota_File )
    FileDelete( $Personal_Quota_File )
    FileDelete( $Teams_Quota_File )
    ; Create the quota.txt file
    Fileopen( $Auto_Quota_File , 2 )
    FileWrite( $Auto_Quota_File, "G:Personal,1.00GB,[Source Io Owner Email]" & @CRLF )
    FileWrite( $Auto_Quota_File, "G:Teams,1.00GB,[Source Io Owner Email]" )
    FileClose ( $Auto_Quota_File )
    Go_Main_Gui()

   Case $v_selection = $get_button
    GUIDelete()
    If FileExists($Quota_Dat_File) Then FileDelete($Quota_Dat_File)
    If FileExists($Auto_Dat_File) Then FileDelete($Auto_Dat_File)
    $remote = InputBox( "Get Source Server", "Please enter the name of the server you want to get the FSRM data from:")
    ProgressOn("Progress Meter", "Getting FSRM Quota data....", "0 percent")
    ProgressSet(10, 10 & " percent")
    Sleep(1000)
    ProgressSet(25, 25 & " percent")
    Sleep(1000)
    $pid = _RunDos($OutPut_Dir & "PsExec.exe " & $remote & " C:\Windows\System32\dirquota.exe q l /list-notifications" & " >" & $Quota_Dat_File & " 2>&1")
    ProcessWaitClose($pid)
    ProgressSet(75, 75 & " percent")
    Sleep(1000)
    ProgressSet(100, "Done", "Complete")
    Sleep(500)
    ProgressOff()
    ProgressOn("Progress Meter", "Gettng Auto Quota data....", "0 percent")
    ProgressSet(10, 10 & " percent")
    Sleep(1000)
    ProgressSet(25, 25 & " percent")
    Sleep(1000)
    $pid = _RunDos($OutPut_Dir & "PsExec.exe " & $remote & " C:\Windows\System32\dirquota.exe auto l /list-notifications" & " >" & $Auto_Dat_File & " 2>&1")
    ProcessWaitClose($pid)
    ProgressSet(75, 75 & " percent")
    Sleep(1000)
    ProgressSet(100, "Done", "Complete")
    Sleep(500)
    ProgressOff()
    If FileExists($Quota_File) Then FileDelete($Quota_File)
    If FileExists($Auto_Quota_File) Then FileDelete($Auto_Quota_File)
    If Not _FileReadToArray($Quota_Dat_File, $FileArray_1) Then
     MsgBox(0, "Error", "Unable to open Quota Input Report file." & @CRLF & @CRLF & "Please run a new report.")
     Go_Main_Gui()
    EndIf
    If Not _FileReadToArray($Auto_Dat_File, $FileArray_2) Then
     MsgBox(0, "Error", "Unable to open Quota AUTO Input Report file." & @CRLF & @CRLF & "Please run a new report.")
     Go_Main_Gui()
    EndIf
    Parse_Quota()
    Parse_Auto()
    If FileExists($Quota_Dat_File) Then FileDelete($Quota_Dat_File)
    If FileExists($Auto_Dat_File) Then FileDelete($Auto_Dat_File)
    If FileExists($OutPut_Dir & "psexec.exe") Then FileDelete($OutPut_Dir & "psexec.exe")
    Go_Main_Gui()
   Case $v_selection = $import_button
    GUIDelete()
    ;********************** Read Quota file and convert to multi dimension array **********************
    If Not _FileReadToArray($Quota_File, $Quota_Array) Then
     MsgBox(0, "Error", "Unable to open Quota Input file." & @CRLF & @CRLF & "Please fix it.  Try the tools menu to parse DAT files.")
     Go_Main_Gui()
    EndIf
    dim $tmpArray
    dim $x
    $x=$Quota_Array[0]
    Dim $New_Quota_Array[50][5]
    reDim $New_Quota_Array[$x + 1][5]
    for $r = 0 To UBound($New_Quota_Array,1) -1
     $tmpArray = StringSplit($Quota_Array[$r], ",")
     for $c = 1 to UBound($tmpArray) -1
      $c1 = $c -1
      $New_Quota_Array[$r][$c1] = $tmpArray[$c]
     Next
    Next
     ; _ArrayDisplay( $New_Quota_Array )
    ;********************** Read Auto Quota file and convert to multi dimension array **********************
    If Not _FileReadToArray($Auto_Quota_File, $Auto_Quota_Array) Then
     MsgBox(0, "Error", "Unable to open Auto Quota Input file." & @CRLF & @CRLF & "Please fix it.  Try the tools menu to parse DAT files.")
     Go_Main_Gui()
    EndIf
    dim $tmpArray
    dim $x
    $x=$Auto_Quota_Array[0]
    Dim $New_Auto_Quota_Array[50][5]
    reDim $New_Auto_Quota_Array[$x + 1][5]
    for $r = 0 To UBound($New_Auto_Quota_Array,1) -1
     $tmpArray = StringSplit($Auto_Quota_Array[$r], ",")
     for $c = 1 to UBound($tmpArray) -1
      $c1 = $c -1
      $New_Auto_Quota_Array[$r][$c1] = $tmpArray[$c]
     Next
    Next
    ; _ArrayDisplay( $New_Auto_Quota_Array )

    ; ********************** Create Personal and Teams quotas based on data in Quota file array **********************
    ;$hard_soft = InputBox("Please make a selection.", "Hard or Soft ???", "HARD")
    ;$mod_add = InputBox("Please make a selection.", "Adding or Modify ???", "a")
    ProgressOn("Please wait", "Creating quotas .......", "0 percent")
    $UpperLimit = UBound($New_Quota_Array,1) -1
    For $LineNumber = 1 To $UpperLimit
     $i = Round(($LineNumber / $UpperLimit) * 100, 0)
     ProgressSet($i, $i & " percent   ")
     $pid1 = _RunDos('echo Notification=m > ' & $85_config_File)
     $pid1 = _RunDos('echo To=' & $New_Quota_Array[$LineNumber][2] & ' >> ' & $85_config_File)
     $pid1 = _RunDos('echo From=QuotaAdministrator@.com >> ' & $85_config_File)
     $pid1 = _RunDos('echo Subject=[Quota Threshold]% quota threshold approaching. >> ' & $85_config_File)
     $pid1 = _RunDos('echo Message=The [Quota Threshold]% quota threshold is approaching for your quota on the folder located on >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo [Quota Path] >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo The quota limit is [Quota Limit MB] MB and [Quota Used MB] MB currently is in use. ([Quota Used Percent]% of limit). >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo In accordance with policies, please ensure that you 5S your data regularly. >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo If you have any issues or concerns, please contact your local helpdesk for further assistance. >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo Please do not reply to this email.>> ' & $85_config_File)
     $pid1 = _RunDos('echo The 85 config file was created for path "' & $New_Quota_Array[$LineNumber][0] & '">> ' & $ErrorFile)

     $pid1 = _RunDos('echo Notification=m > ' & $100_config_File)
     $pid1 = _RunDos('echo To=' & $New_Quota_Array[$LineNumber][2] & ' >> ' & $100_config_File)
     $pid1 = _RunDos('echo From=QuotaAdministrator@.com >> ' & $100_config_File)
     $pid1 = _RunDos('echo Subject=[Quota Threshold]% quota threshold exceeded. >> ' & $100_config_File)
     $pid1 = _RunDos('echo Message=You have exceeded your [Quota Threshold]% quota threshold for your quota on the folder located on >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo [Quota Path] >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo The quota limit is [Quota Limit MB] MB and [Quota Used MB] MB currently is in use. ([Quota Used Percent]% of limit). >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo In accordance with policies, please ensure that you 5S your data regularly. >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo If you have any issues or concerns, please contact your local helpdesk for further assistance. >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo Please do not reply to this email.>> ' & $100_config_File)
     $pid1 = _RunDos('echo The 100 config file was created for path "' & $New_Quota_Array[$LineNumber][0] & '" >> ' & $ErrorFile)
     $FixedLimitArray = StringSplit($New_Quota_Array[$LineNumber][1], ".00", 1)
     $FixedLimit = $FixedLimitArray[1] & $FixedLimitArray[2]
     ;$pid1 = _RunDos('C:\Windows\System32\dirquota.exe q a /path:"' & $New_Quota_Array[$LineNumber][0] & '" /Limit:' & $FixedLimit & ' /Type:HARD /Add-Threshold:85 /Add-Threshold:100 /Add-notification:85,m,' & $85_config_File & ' /Add-Notification:100,m,' & $100_config_File & ' >> ' & $ErrorFile & ' 2>&1')
     ;$pid2 = _Rundos("C:\Windows\System32\dirquota.exe quota list > c:temperr.txt 2>&1")
     $pid2 = ShellExecute("dirquota", "quota list > c:temperr.txt 2>&1")
     ProcessWaitClose($pid2)
     $pid1 = _RunDos('echo. >> ' & $ErrorFile)

     If $LineNumber = $UpperLimit Then
      ProgressSet(100, "Done", "Complete")
      Sleep(500)
      ProgressOff()
     EndIf
    Next

    ; ********************** Create AUTO quotas based on data in Auto Quota file array **********************
    ;$hard_soft = InputBox("Please make a selection.", "Hard or Soft ???", "HARD")
    ;$mod_add = InputBox("Please make a selection.", "Adding or Modify ???", "a")
    $pid1 = _RunDos('echo. >> ' & $ErrorFile)
    $pid1 = _RunDos('echo. >> ' & $ErrorFile)
    $pid1 = _RunDos('echo. >> ' & $ErrorFile)
    ProgressOn("Please wait", "Creating Auto quotas .......", "0 percent")
    $UpperLimit = UBound($New_Auto_Quota_Array,1) -1
    For $LineNumber = 1 To $UpperLimit
     $i = Round(($LineNumber / $UpperLimit) * 100, 0)
     ProgressSet($i, $i & " percent   ")
     $pid1 = _RunDos('echo Notification=m > ' & $85_config_File)
     $pid1 = _RunDos('echo To=' & $New_Auto_Quota_Array[$LineNumber][2] & ' >> ' & $85_config_File)
     $pid1 = _RunDos('echo From=QuotaAdministrator@.com >> ' & $85_config_File)
     $pid1 = _RunDos('echo Subject=[Quota Threshold]% quota threshold approaching. >> ' & $85_config_File)
     $pid1 = _RunDos('echo Message=The [Quota Threshold]% quota threshold is approaching for your quota on the folder located on >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo [Quota Path] >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo The quota limit is [Quota Limit MB] MB and [Quota Used MB] MB currently is in use. ([Quota Used Percent]% of limit). >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo In accordance with policies, please ensure that you 5S your data regularly. >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo If you have any issues or concerns, please contact your local helpdesk for further assistance. >> ' & $85_config_File)
     $pid1 = _RunDos('echo >> ' & $85_config_File)
     $pid1 = _RunDos('echo Please do not reply to this email.>> ' & $85_config_File)
     $pid1 = _RunDos('echo The 85 config file was created for path "' & $New_Auto_Quota_Array[$LineNumber][0] & '" >> ' & $ErrorFile)

     $pid1 = _RunDos('echo Notification=m > ' & $100_config_File)
     $pid1 = _RunDos('echo To=' & $New_Auto_Quota_Array[$LineNumber][2] & ' >> ' & $100_config_File)
     $pid1 = _RunDos('echo From=QuotaAdministrator@.com >> ' & $100_config_File)
     $pid1 = _RunDos('echo Subject=[Quota Threshold]% quota threshold exceeded. >> ' & $100_config_File)
     $pid1 = _RunDos('echo Message=You have exceeded your [Quota Threshold]% quota threshold for your quota on the folder located on >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo [Quota Path] >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo The quota limit is [Quota Limit MB] MB and [Quota Used MB] MB currently is in use. ([Quota Used Percent]% of limit). >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo In accordance with policies, please ensure that you 5S your data regularly. >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo If you have any issues or concerns, please contact your local helpdesk for further assistance. >> ' & $100_config_File)
     $pid1 = _RunDos('echo >> ' & $100_config_File)
     $pid1 = _RunDos('echo Please do not reply to this email.>> ' & $100_config_File)
     $pid1 = _RunDos('echo The 100 config file was created for path "' & $New_Auto_Quota_Array[$LineNumber][0] & '" >> ' & $ErrorFile)
     $pid1 = _RunDos('C:\Windows\System32\dirquota.exe auto a /path:"' & $New_Auto_Quota_Array[$LineNumber][0] & '"  /sourcetemplate:"1Gb Quota Limit HQ" /Add-Threshold:85 /Add-Threshold:100 /Add-notification:85,m,' & $85_config_File & ' /Add-Notification:100,m,' & $100_config_File & ' >> ' & $ErrorFile & ' 2>&1')
     ProcessWaitClose($pid1)
     $pid1 = _RunDos('echo. >> ' & $ErrorFile)
     If $LineNumber = $UpperLimit Then
      ProgressSet(100, "Done", "Complete")
      Sleep(500)
      ProgressOff()
     EndIf
    Next
;~   If FileExists($85_config_File) Then
;~     FileDelete($85_config_File)
;~    EndIf
;~   If FileExists($100_config_File) Then
;~     FileDelete($100_config_File)
;~    EndIf
    Go_Main_Gui()

   Case $v_selection = $hard_button
    GUIDelete()
    If Not _FileReadToArray($Quota_File, $FileArray_1) Then
     MsgBox(0, "Error", "Unable to open Quota Input Report file." & @CRLF & @CRLF & "Please run a new report.")
     Exit
    EndIf
    Dim $array_line[4]
    $array_line[0] = 3
    ProgressOn("Please wait", "Converting quotas to hard .......", "0 percent")
    For $LineNumber = 1 To $FileArray_1[0] ; Read each line
     $i = Round(($LineNumber / $FileArray_1[0]) * 100, 0)
     ProgressSet($i, $i & " percent")
     $split_array = StringSplit($FileArray_1[$LineNumber], ',', 1)
     $pid = _RunDos('C:\Windows\System32\dirquota.exe q m /type:HARD /path:' & $split_array[1] & " >>" & $ErrorFile & " 2>&1")
     ProcessWaitClose($pid)
     If $LineNumber = $FileArray_1[0] Then
      ProgressSet(100, "Done", "Complete")
      Sleep(500)
      ProgressOff()
     EndIf
    Next
    Go_Main_Gui()

   Case $v_selection = $change_button
    GUIDelete()
    $file = FileOpenDialog("Open file", "", "All files (*.*;)", 1, "List.csv")
    If @error Then
     MsgBox(4096, "", "No File(s) chosen")
    Else
     ; MsgBox(4096,"","You chose " & $file)
     If Not _FileReadToArray($file, $FileArray_1) Then
      MsgBox(0, "Error", "Unable to open Quota Input Report file." & @CRLF & @CRLF & "Please run a new report.")
      Go_Main_Gui()
     EndIf
     $hard_soft = InputBox("Please make a selection.", "Hard or Soft ???", "HARD")
     $mod_add = InputBox("Please make a selection.", "Adding or Modify ???", "a")
     Dim $array_line[4]
     $array_line[0] = 3
     ProgressOn("Please wait", "Modifying quotas .......", "0 percent")
     For $LineNumber = 1 To $FileArray_1[0] ; Read each line
      $i = Round(($LineNumber / $FileArray_1[0]) * 100, 0)
      $split_array = StringSplit($FileArray_1[$LineNumber], ',', 1)
      ProgressSet($i, $i & " percent   " & $split_array[1])
      FileWriteLine($ErrorFile, $split_array[1])
      $pid = _RunDos('C:\Windows\System32\dirquota.exe q ' & $mod_add & ' /type:' & $hard_soft & ' /path:' & $split_array[1] & " /limit:" & $split_array[2] & " >> " & $ErrorFile & " 2>&1")
      FileWriteLine($ErrorFile, @CRLF & @CRLF)
      ProcessWaitClose($pid)
      If $LineNumber = $FileArray_1[0] Then
       ProgressSet(100, "Done", "Complete")
       Sleep(500)
       ProgressOff()
      EndIf
     Next
     Go_Main_Gui()
    EndIf

   Case $v_selection = $helpmenu_contents
    MsgBox(0, $ProgName, "This program will:" & @CRLF & @CRLF & "1. " & @CRLF & "2. " & @CRLF & "3. " & @CRLF & "4. " & @CRLF & "5. " & @CRLF & @CRLF & @CRLF)

   Case $v_selection = $helpmenu_about
    MsgBox(0, $ProgName, "  Written By: Lee" & @CRLF & "       Version: " & $prog_ver & @CRLF & "     Created: 12/14/2011" & @CRLF & "    Modified: " & $mod_date)

   Case Else
    ;;;
  EndSelect
WEnd
EndFunc
Func _ExcelGetUsedRange(ByRef $oExcel)
    ; Get size of current sheet as R1C1 string
    ; -4150 specifies that the address is returned in R1C1 string format
    ; SpecialCells(11) refers to the last used cell in the active worksheet
    Local $sLastCell = $oExcel.Application.Selection.SpecialCells(11).Address(True, True, -4150)
    ; Extract integer last row and col
    $sLastCell = StringRegExp($sLastCell, "A[^0-9]*(d+)[^0-9]*(d+)Z", 3)
    Local $iLastRow = $sLastCell[0]
    Local $iLastColumn = $sLastCell[1]
    ; Return 0 if the sheet is blank
    If $sLastCell = "R1C1" And $oExcel.Activesheet.Cells($iLastRow, $iLastColumn).Value = "" Then
        Return 0
    EndIf
    Dim $aUsedRange[2]
    $aUsedRange[0]=$sLastCell[0]
    $aUsedRange[1]=$sLastCell[1]
    Return $aUsedRange
EndFunc
Func Parse_Quota()
Dim $array_line[4]
$array_line[0] = 3
ProgressOn("Please wait", "Parsing Quota data.......", "0 percent")
For $LineNumber = 1 To $FileArray_1[0] ; Read each line
  $i = Round(($LineNumber / $FileArray_1[0]) * 100, 0)
  ProgressSet($i, $i & " percent")
  ;Find a line with "Quota Path:" on it and grab the Path of the Quota.
  If StringLeft($FileArray_1[$LineNumber], 11) = "Quota Path:" Then
   If $LineNumber > 1 Then $array_line = dumparray($array_line, $Quota_File)
   $array_line[1] = StringMid($FileArray_1[$LineNumber], 25)
  EndIf
  ;Then find a line with "Limit:" on it and grab the Quota Limit and add it to the output line.
  If StringLeft($FileArray_1[$LineNumber], 6) = "Limit:" Then
   $limitfix1 = StringMid($FileArray_1[$LineNumber], 25)
   $limitfix2 = StringStripWS($limitfix1, 8)
   $removeme1 = _StringBetween($limitfix2, '(', ')')
   $remove2 = $removeme1[0]
   $limitfix3 = StringReplace($limitfix2, $remove2, "")
   $limitfix4 = StringReplace($limitfix3, "(", "")
   $limitfix5 = StringReplace($limitfix4, ")", "")
   $array_line[2] = $limitfix5
  EndIf
  ;Find next line with "Mail To" and grab the FIRST one and add it to the output line.
  If StringLeft($FileArray_1[$LineNumber], 11) = "   Mail To:" Then
   $array_line[3] = StringMid($FileArray_1[$LineNumber], 33)
  EndIf

  If $LineNumber = $FileArray_1[0] Then
   ProgressSet(100, "Done", "Complete")
   Sleep(500)
   ProgressOff()
  EndIf
Next
dumparray($array_line, $Quota_File)
_FileWriteToLine($Quota_File, 1, "", 1)
FileClose($Quota_Dat_File)
FileClose($Quota_File)
EndFunc
Func Parse_Auto()
Dim $array_line[4]
$array_line[0] = 3
ProgressOn("Please wait", "Parsing Auto Quota data.......", "0 percent")
For $LineNumber = 1 To $FileArray_2[0] ; Read each line
  $i = Round(($LineNumber / $FileArray_2[0]) * 100, 0)
  ProgressSet($i, $i & " percent")
  ;Find a line with "Auto Quota Path:" on it and grab the Path of the Quota
  If StringLeft($FileArray_2[$LineNumber], 22) = "Auto Apply Quota Path:" Then
   If $LineNumber > 1 Then $array_line = dumparray($array_line, $Auto_Quota_File)
   $array_line[1] = StringMid($FileArray_2[$LineNumber], 25)
  EndIf
  ;Then find a line with "Limit:" on it and grab the Quota Limit and add it to the output line
  If StringLeft($FileArray_2[$LineNumber], 6) = "Limit:" Then
   $limitfix1 = StringMid($FileArray_2[$LineNumber], 25)
   $limitfix2 = StringStripWS($limitfix1, 8)
   $removeme1 = _StringBetween($limitfix2, '(', ')')
   $remove2 = $removeme1[0]
   $limitfix3 = StringReplace($limitfix2, $remove2, "")
   $limitfix4 = StringReplace($limitfix3, "(", "")
   $limitfix5 = StringReplace($limitfix4, ")", "")
   $array_line[2] = $limitfix5
  EndIf
  ;Find next line with Mail To and grab the FIRST one and add it to the output line
  If StringLeft($FileArray_2[$LineNumber], 11) = "   Mail To:" Then
   $array_line[3] = StringMid($FileArray_2[$LineNumber], 33)
  EndIf

  If $LineNumber = $FileArray_2[0] Then
   ProgressSet(100, "Done", "Complete")
   Sleep(500)
   ProgressOff()
  EndIf
Next
dumparray($array_line, $Auto_Quota_File)
_FileWriteToLine($Auto_Quota_File, 1, "", 1)
FileClose($Auto_Dat_File)
FileClose($Auto_Quota_File)
EndFunc
Func dumparray($array, $fh)
FileWriteLine($fh, _ArrayToString($array, ",", 1))
Dim $line[5]
$line[0] = 4
Return $line
EndFunc
Func Done_Check()
If FileExists($OutPut_Dir & "psexec.exe") Then
  FileDelete($OutPut_Dir & "psexec.exe")
EndIf
If FileExists($Quota_Dat_File) Then
  FileDelete($Quota_Dat_File)
EndIf
If FileExists($Auto_Dat_File) Then
  FileDelete($Auto_Dat_File)
EndIf
Exit
EndFunc
Link to comment
Share on other sites

When you use Run you have to specify an EXE or BAT or ... file (for details please check the help file).

So this might return a result.

Run("C:\Windows\System32\dirquota.exe quota list >> g:quotareportserr.txt 2>&1", "C:\Windows\System32\")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks for the suggestion.

I have already tried adding and removing the ".exe"

I tried changing all the the double quotes to single quotes.

Run('C:\Windows\System32\dirquota.exe quota list >> g:quotareportserr1.txt 2>&1', 'C:\Windows\System32\')   <---dosent work

_RunDos(@COMSPEC & ' /c C:\Windows\System32\dirquota.exe quota list >> g:quotareportserr2.txt 2>&1')  <---dosent work
RunWait( @COMSPEC & ' /c Echo On&&G:&&cd quotareports&&dir>multi.txt', '', @SW_HIDE )  <---works!!!!
RunWait( @COMSPEC & ' /c dirquota.exe quota list >> g:quotareportserr3.txt 2>&1', '', @SW_HIDE )   <---dosent work
Link to comment
Share on other sites

  • Moderators

This may or may not help, but I tried this out on one of my 2008 R2 boxes. For me, dirquota was not in the System32 directory. The script did not work when I copied it there; AutoIT stated it could not find the executable even though the path was clearly defined. I was able to successfully call it when I copied to the root of C: though, so perhaps a permissions issue?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

JLogan3o13 - thanks. I actually tried that too.

I think I figured it out. I compiled it with 64bit and it seems to be working. I need to do a little more testing. but I think its working.

Thanks to everyone for their input.

Link to comment
Share on other sites

This works for me:

#AutoIt3Wrapper_UseX64=y
#include <constants.au3>
Global $sOutput = @ScriptDir & "Err.txt"
If FileExists($sOutput) Then FileDelete($sOutput)
Global $sCommand = "DirQuota.exe "
Global $sParameter = "quota list >> " & $sOutput & " 2>&1"

Global $sData
Global $pid = Run(@ComSpec & " /c " & $sCommand & $sParameter, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While 1
    $sData &= StdoutRead($pid)
    If @error Then ExitLoop
;~  ConsoleWrite(StderrRead($pid) & @LF)
    Sleep(20)
Wend
MsgBox(0, "Test", FileRead($sOutput))

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Here are two more examples, that are similar to how UEZ wrote his, but reads STDOUT and writes the file with FileWrite.

x64

#AutoIt3Wrapper_UseX64=y
#include <Constants.au3>
Global $sFileOut = @ScriptDir & "Err.txt"
If FileExists($sFileOut) Then FileDelete($sFileOut)

Global $iPID = Run("DirQuota quota list", @SystemDir, @SW_HIDE, $STDERR_MERGED)

ProcessWaitClose($iPID)
Global $sFile = StdoutRead($iPID)
FileWrite($sFileOut, $sFile)

MsgBox(0, "Test", FileRead($sFileOut))

x86: Turns off redirection.

#AutoIt3Wrapper_UseX64=n
#include <Constants.au3>
Global $sFileOut = @ScriptDir & "Err.txt"
If FileExists($sFileOut) Then FileDelete($sFileOut)

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) ;Turn off Redirection.
Global $iPID = Run("DirQuota quota list", @WindowsDir & "System32", @SW_HIDE, $STDERR_MERGED) ;@SystemDir returns @WindowsDir & "SYSWOW64" under 32-bit.

ProcessWaitClose($iPID)
Global $sFile = StdoutRead($iPID)
FileWrite($sFileOut, $sFile)

MsgBox(0, "Test", FileRead($sFileOut))

Adam

Edited by AdamUL
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...