Guest sydullasyed Posted August 18, 2006 Posted August 18, 2006 Hi, Using AutoIt can we send the output of "net view\\(systemname)"command to a text file? if anybody knows please assist me
Xenobiologist Posted August 18, 2006 Posted August 18, 2006 (edited) HI, use Run and @compsec or _RunDos and use the command net view \\name > netview.txt Likely this way: #include<Process.au3> _RunDOS("net view > c:\netview.txt") So long, Mega Edited August 18, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Guest sydullasyed Posted August 21, 2006 Posted August 21, 2006 HI, use Run and @compsec or _RunDos and use the command net view \\name > netview.txt Likely this way: #include<Process.au3> _RunDOS("net view > c:\netview.txt") So long, Mega Hi, Thanks for sending the solution it's storing the whole o/p in the txt file(netview.txt). it is as follows ================================================== Shared resources at \\sydsye XXXX Share name Type Used as Comment ------------------------------------------------------------------------------- sc Disk testshare Disk testshare The command completed successfully. ==================================================== Here with this i need to check the sharename (sc) either it exists or not since all the o/p exists in txtfile i am thinking that move only the table to other txt file so that i can easily check for the share namesnetview.txt
Xenobiologist Posted August 21, 2006 Posted August 21, 2006 HI, sorry what? The file is empty. If you want to check whether there is a special string in the txtfile then read it into an array with _FileReadToArray() and check every line with StringInStr <> 0 Then "Juhu" ... So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Guest sydullasyed Posted August 21, 2006 Posted August 21, 2006 HI,sorry what? The file is empty. If you want to check whether there is a special string in the txtfile then read it into an array with _FileReadToArray() and check every line with StringInStr <> 0 Then "Juhu" ...So long,MegaHi File contais the following information.....Shared resources at \\sydsyessssShare name Type Used as Comment -------------------------------------------------------------------------------sc Disk testshare Disk testshare The command completed successfully.i need only the share names (so that i can check the existance of share names)if we move only the share names to other txt file i think it's easy to check.is there any way how to send only the share names ?or else can we check here itself (i.e. with in this file only)"Please assist me
Guest sydullasyed Posted August 22, 2006 Posted August 22, 2006 Hi File contais the following information.....Shared resources at \\sydsyessssShare name Type Used as Comment -------------------------------------------------------------------------------sc Disk testshare Disk testshare The command completed successfully.i need only the share names (so that i can check the existance of share names)if we move only the share names to other txt file i think it's easy to check.is there any way how to send only the share names ?or else can we check here itself (i.e. with in this file only)"Please assist meHiFile contais the following information.....============================Shared resources at \\sydsyessssShare name Type Used as Comment-------------------------------------------------------------------------------sc Disktestshare Disk testshareThe command completed successfully.==================================================i need only the share names (so that i can check the existance of share names)if we move only the share names to other txt file i think it's easy to check.is there any way how to send only the share names ?or else can we check here itself (i.e. with in this file only)"Please assist me
BPBNA Posted August 22, 2006 Posted August 22, 2006 Run now has a parameter to see the write, output or error streams of the child process. $output = Run(@ComSpec & " /c C:\MyProg.exe", "", @SW_HIDE, $STDOUT_CHILD+$STDERR_CHILD) Take a look at the StdoutRead() and StderrRead() functions.
Danny35d Posted August 22, 2006 Posted August 22, 2006 I create an UDF which give you an array with at list of printer shares or disk shares. _NetView('\\ServerName', 'print') will give you a list of printer shares. _NetView('\\ServerName') will give you a list of disk shares.expandcollapse popup#include <Array.au3> $Server = InputBox('Enter Server', 'Enter server name or ip address.') ;$ServerList = _NetView($Server, 'print') ; Return Array with print share $ServerList = _NetView($Server) ; Return Array with disk share $error = @error If Not IsArray($ServerList) Then MsgBox(0, $ServerList, $error) _ArrayDisplay($ServerList, $error) Exit ;========================================================================================== ; ; Description: NewView, get a list of disk or printer shares (Windows or Novell) ; Syntax: _NetView($sServerName, [$sType = 'disk', $iNovell = 0]) ; ; Parameter(s): $sServerName = 'Server Name or Ip Address' ; $sType = disk - Give you an array with all disk share (default) ; print - Give you an array with all printer share ; $iNovell = 0 (default) or 1 to query Novell share list ; ; Requirement(s): $sServerName ; Return Value(s): On Success - Return an array with all disk or printer share ; On Failure - Return "" and set the @error flag: ; 0 - No error. ; 1 - If file not opened in read mode or other error. ; 2 - If file not exists. ; 3 - No disk or printer share found. ; 4 - Wrong $sType, use either 'disk' or 'print' ; Author(s): Danny35d ; ;========================================================================================== Func _NetView($sServerName, $sType = 'disk', $iNovell = 0) Local $LineCount = 5, $sPrinterList = '', $sCmdLine = '' $sServerName = StringReplace($sServerName, '\', '') If $sType == -1 Then $sType = 'disk' If $iNovell <> 0 Then $sCmdLine = ' /network:nw' If StringLower($sType) <> 'disk' And StringLower($sType) <> 'print' Then SetError(4) Return('') EndIf RunWait(@ComSpec & ' /c net view \\' & $sServerName & $sCmdLine & ' > ' & @TempDir & '\NetView.txt', @TempDir, @SW_HIDE) If FileExists(@TempDir & '\NetView.txt') Then While 1 $Line = FileReadLine(@TempDir & '\NetView.txt', $LineCount) If @error == -1 Or @error == 1 Then If @error == 1 Then FileDelete(@TempDir & '\NetView.txt') SetError(1) Return('') EndIf ExitLoop EndIf $LineCount += 1 $Line = StringSplit($Line, ' ') If _ArraySearch($Line, $sType) <> -1 Then $sPrinterList &= '|' & $Line[1] WEnd $sPrinterList = StringTrimLeft($sPrinterList, 1) FileDelete(@TempDir & '\NetView.txt') Else SetError(2) Return('') EndIf If $sPrinterList <> '' Then SetError(0) Return(StringSplit($sPrinterList, '|')) Else SetError(3) Return('') EndIf EndFunc AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
PsaltyDS Posted August 22, 2006 Posted August 22, 2006 (edited) Hi, Thanks for sending the solution it's storing the whole o/p in the txt file(netview.txt). it is as follows ================================================== Shared resources at \\sydsye XXXX Share name Type Used as Comment ------------------------------------------------------------------------------- sc Disk testshare Disk testshare The command completed successfully. ==================================================== Here with this i need to check the sharename (sc) either it exists or not since all the o/p exists in txtfile i am thinking that move only the table to other txt file so that i can easily check for the share names If you know which share you are looking for ahead of time, you can let the DOS command line check it for you: $SystemName = @ComputerName ; Change to remote computer name if required $ShareName = "sc" ; Change to the share you are looking for $ExtCmd = 'NET VIEW \\' & $SystemName & ' | FIND /i "Disk" | FIND "' & $ShareName & '"' $ErrorLevel = RunWait(@ComSpec & " /c " & $ExtCmd, @TempDir, @SW_MINIMIZE) If $ErrorLevel = 0 Then MsgBox(64, "Results", "The share \\" & $SystemName & "\" & $ShareName & " exists.") Else MsgBox(16, "Results", "The share \\" & $SystemName & "\" & $ShareName & " does not exist.") EndIfoÝ÷ Ø!·¥ëÞ¶WÆ+-±û§rبƧr¥ ëÞæ¬êÚºÚ"µÍÌÍÔÞÝ[S[YHHÛÛ][YHÈÚ[ÙHÈ[[ÝHÛÛ][YHY]ZYÌÍÔÚS[YHH ][ÝÜØÉ][ÝÈÈÚ[ÙHÈHÚH[ÝHHÛÚÚ[ÈÜÌÍÕÝSÈH ÌÎNÉÌLÉÌLÉÌÎNÈ [È ÌÍÔÞÝ[S[YH [È ÌÎNÉÌLÉÌÎNÈ [È ÌÍÔÚS[YH [È ÌÎNÉÌLÉÌÎNÂY[Q^ÝÊ ÌÍÕÝSÊH[ÙÐÞ ][ÝÔÝ[É][ÝË ][ÝÕHÚH ][ÝÈ [È ÌÍÕÝSÈ [È ][ÝÈ^ÝË][ÝÊB[ÙBÙÐÞ ][ÝÔÝ[É][ÝË ][ÝÕHÚH ][ÝÈ [È ÌÍÕÝSÈ [È ][ÝÈÙÈÝ^Ý][ÝÊB[Y Edited August 22, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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