farma Posted February 1, 2006 Posted February 1, 2006 Is it possible to realize this batch part??? set errorlevel= lpr -S %printer% -P %printer% %temp%\test.txt|find /i /c "Error" >nul if %errorlevel% EQU 0 ( call :fehler "Directprint %printer% not possible" ) ELSE ( call :ok "Directprint %printer% ok" ) echo.
PsaltyDS Posted February 1, 2006 Posted February 1, 2006 (edited) Is it possible to realize this batch part??? set errorlevel= lpr -S %printer% -P %printer% %temp%\test.txt|find /i /c "Error" >nul if %errorlevel% EQU 0 ( call :fehler "Directprint %printer% not possible" ) ELSE ( call :ok "Directprint %printer% ok" ) echo. You can run the LPR command and handle the error level inside AutoIT: $Printer = "MyPrinter" $LprCmd = "lpr -S " & $Printer & " -P " & $Printer & " " & @TempDir & "\test.txt" $ErrLvl = RunWait($LprCmd, @TempDir, @SW_SHOW) If $ErrLvl = 0 Then MsgBox(32, "LPR Worked", "The LPR command was successfull.") Else MsgBox(16, "LPR Failed", "Error executing: " & $LprCmd & @CRLF & _ "%ErrorLevel% was: " & $ErrLvl) EndIf Hope that helps! Edited February 1, 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
PsaltyDS Posted February 2, 2006 Posted February 2, 2006 Thanks for all your help!! But I have still a Problem I try to check ping without and with suffix and the suffix that work should be the ne variable. I thought that this would work but there is something wrong. $suf1="muc" $suf2="w1" $suf3="w2" $suf4="w3" $suf5="w4" $suf6="w5" $suf7="w6" $suf8="w7" $suf9="w8" $suf10="w12" $suf11="w34" $suf12="w50" $suf13="bank" $suf14="al.group-net.de" $suf15="" for $ps = $suf1 to $suf15 $var = Ping(GUICtrlRead($remotepc)& $ps,250) If $var then $rempc = GUICtrlRead($remotepc) & $ps Msgbox(0,"Status","Online!!!") ELSE $error = "Host is offline" & @CRLF & "or" & @CRLF & "unreachable" Msgbox(0,"Status","ERROR" & @CRLF & $error) ENDIF NEXT I think you misunderstand the For/Next loop. Take the example: For $x = $y to $z The loop repeats, replacing the first variable $x each time with the stepped integers from $y to z$. So in your code above, $ps will be replaced with the integers from $suf1 to $suf15, except you did NOT set those to integer values. If you want to read out a series of values, you put them in an Array, like this: Dim $Suf[15] ; This creates the array with 15 elements (0 - 14) $Suf[0]="muc" $Suf[1]="w1" $Suf[2]="w2" $Suf[3]="w3" $Suf[4]="w4" $Suf[5]="w5" $Suf[6]="w6" $Suf[7]="w7" $Suf[8]="w8" $Suf[9]="w12" $Suf[10]="w34" $Suf[11]="w50" $Suf[12]="bank" $Suf[13]="al.group-net.de" $Suf[14]="" For $r = 0 to 14 $ps = $Suf[$r] ; Your looped code goes here ; It will be repeated 15 times with the various values for $ps Next Inside your loop, I'm not sure what you are doing. What is the control your are reading with the "GUICtrlRead($remotepc)" functions? 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
farma Posted February 2, 2006 Author Posted February 2, 2006 GUICtrlRead($remotepc) reads the PC name, IP or Printername You enter a PC Name like "mypc" And the script should check if ping is possible without or with suffix. (like "mypc.w1") If Ping is possible with or without suffix set the variable "mypc" = "mypc" & ".w1" so you get the new variable "mypc.w1" Then I check if direct print is possible
farma Posted February 2, 2006 Author Posted February 2, 2006 (edited) This is my tool what i'm talking about The DWRC-Clean Button: (DWRC is Dameware Remote Access) Cleans the eventviewer an delete the DWRC files on the remote pc The Ping Button: Ping ^^ The Printer Button: Checks the if the Printer is online and directprint is possible. The Power-Off button: Exit expandcollapse popup#Include <GUIConstants.au3> #include <Constants.au3> While 1 GUICreate("farma's Toolbox", 300,170,) GUISetFont (10,400) GUICtrlCreateLabel ("Enter PC-Name, Printer or IP!", 5,20) GUISetFont (-1,15,400) $remotepc =GUICtrlCreateInput ("localhost", 5,50,200,20) GUICtrlCreateLabel (Chr(169) & " Farma", 5,150) GUISetFont (8,400) $exit = GUICtrlCreateButton ("3", 255,105,40,40,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",27) GUISetFont (-1,12,400) $DWRC = GUICtrlCreateButton ("DWRC Clean", 5,105,80,40) $ping = GUICtrlCreateButton ("PING", 90,105,40,40) $druck = GUICtrlCreateButton ("3", 135,105,40,40,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",82) $n1 = GUICtrlCreateIcon (@windowsdir & "\cursors\banana.ani",-1, 260,65,40,40) GUISetState(@SW_SHOW) While 2 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $ping $var = Ping(GUICtrlRead($remotepc),250) If $var Then; also possible: If @error = 0 Then ... Msgbox(0,"Status","Online!!!") Else $error = "Host is offline" & @CRLF & "or" & @CRLF & "unreachable" Msgbox(0,"Status","ERROR" & @CRLF & $error) EndIf Case $msg =$druck FileDelete (@TempDir & "\test.txt") $file = FileOpen(@TempDir & "\test.txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") EndIf FileWriteLine($file,"TESTSEITE") FileClose($file) GUICreate("Printer Status", 300, 170,) GUICtrlCreateLabel ("Checking following Printer:", 20,20) GUISetFont (12,800) $printer = GUICtrlCreateLabel ("", 20,40,200,100) GUISetFont (8,400) $ping = GUICtrlCreateLabel ( "", 40,74,200,100) GUICtrlCreateLabel ("NSLookup will not be checkt", 40,108) $ok = GUICtrlCreateicon ("3", 10,5,98,30,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",109) $dprint = GUICtrlCreateLabel ( "", 40,140,200,100) GUISetState() Dim $Suf[15]; This creates the array with 15 elements (0 - 14) $Suf[0]=".muc" $Suf[1]=".w1" $Suf[2]=".w2" $Suf[3]=".w3" $Suf[4]=".w4" $Suf[5]=".w5" $Suf[6]=".w6" $Suf[7]=".w7" $Suf[8]=".w8" $Suf[9]=".w12" $Suf[10]=".w34" $Suf[11]=".w50" $Suf[12]=".bank" $Suf[13]=".al.group-net.de" $Suf[14]="" For $r = 0 to 14 $ps = $Suf[$r] GUICtrlSetData ( $printer,""&GUICtrlRead($remotepc)&$ps) $var = Ping(GUICtrlRead($remotepc)& $ps,40) If $var Then; also possible: If @error = 0 Then ... $ok = GUICtrlCreateicon ("3", 20,8,65,40,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",216) GUICtrlSetData ( $ping,"Ping is OK!!") $rempcsuf = GUICtrlRead($remotepc)&$ps $color1 = "1" sleep(20) Exitloop Else $ok = GUICtrlCreateicon ("3", 10,5,65,40,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",131) GUICtrlSetData ( $ping,"Ping -> not responding!!!!") $color1 = "0" sleep(20) EndIf Next $LprCmd = "lpr -S " & $rempcsuf & " -P " & $rempcsuf & " " & @TempDir & "\test.txt" $ErrLvl = RunWait($LprCmd, @TempDir, @SW_SHOW) If $ErrLvl = 0 Then $ok = GUICtrlCreateicon ("3", 20,8,130,40,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",216) GUICtrlSetData ( $dprint,"Directprint was successfull!!!!") $color1 = $color1 + 2 Else $ok = GUICtrlCreateicon ("3", 10,5,130,40,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",131) GUICtrlSetData ( $dprint,"Directprint not possible!!!!") $color1 = "0" EndIf IF $color1 = 3 then $color ="0x14FF02" ELSE $color ="0xFF3300" Endif $color = GUISetBkColor ($color) sleep(5000) GUIDelete() Case $msg = $DWRC GUICreate("This PC??", 300, 170,) GUISetFont (10,400) GUICtrlCreateLabel ("Is this the correct Name or IP?", 20,20) GUISetFont (15,400) GUICtrlCreateLabel (""& GUICtrlRead($remotepc), 20,55) $yes = GUICtrlCreateButton(" YES ", 20,100,60,40) $no = GUICtrlCreateButton(" NO ", 120,100,60,40) $done = GUICtrlCreateButton ("3", 220,100,60,40,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",27) GUISetState(@SW_SHOW) While 3 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $yes MsgBox(0, "YES", "OK,..." & @CRLF & "Let's go...", 1.5) SplashTextOn("Don't touch!", @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & "DON'T TOUCH THE KEYBOARD" & @CRLF & "OR THE MOUSE!", 500, 400, -1, -1, 2, "", 22) Sleep(4000) $DeletePath = "\\" & GUICtrlRead($remotepc) & "\c$\WINDOWS\system32\DWRC*.*" If FileDelete($DeletePath) Then MsgBox(0, "Message", "Files deleted successfully at:" & @CRLF & @Tab & $DeletePath, 2) Else MsgBox(16, "Error", "Error deleting files at:" & @CRLF & @Tab & $DeletePath, 5) SplashOff ( ) EXITLOOP EndIf run("cmd") Winwait("C:\WINDOWS\system32\cmd.exe") Send("eventvwr "& GUICtrlRead($remotepc)) Send("{ENTER}") Send("exit") Send("{ENTER}") WinWait("Event Viewer") Send("{DOWN}") Sleep(1000) Send("!trn") Send("{DOWN}") Sleep(1000) Send("!trn") Send("{DOWN}") Sleep(1000) Send("!trn") sleep(500) Send("!d+b") WinWaitClose("Event Viewer") SplashOff ( ) MsgBox(0,"Finish", "The DWRC files should be deleted! And the Eventlog should be cleared!", 5) GUIDelete() EXITLOOP Case $msg = $done GUIDelete() EXIT EXITLOOP Case $msg = $no GUIDelete() MsgBox(0, "NO", "OK...", 1) GUIDelete() EXITLOOP EndSelect $msg = $GUI_EVENT_CLOSE Wend GUIDelete() Case $msg = $exit GUIDelete() EXIT EndSelect $msg = $GUI_EVENT_CLOSE Wend GUIDelete() EXITLOOP WEND EXIT Edited February 2, 2006 by farma
flaxcrack Posted February 3, 2006 Posted February 3, 2006 This is my tool what i'm talking aboutThe DWRC-Clean Button: (DWRC is Dameware Remote Access)Cleans the eventviewer an delete the DWRC files on the remote pcThe Ping Button:Ping ^^The Printer Button:Checks the if the Printer is online and directprint is possible.The Power-Off button:ExitAre you doing something evil with DameWare? Why do you need to delete the event logs? [quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD()
farma Posted February 3, 2006 Author Posted February 3, 2006 Are you doing something evil with DameWare? Why do you need to delete the event logs? No, I delete the event log, to see whats happen after my last connect!Normaly I delete the event log while i'm connected, but this is easyer.And I delete the DWRC files because some of my colleague have an older versionof DW and somethimes they got error when they try to connect.
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