Jump to content

sinvos

Members
  • Posts

    6
  • Joined

  • Last visited

sinvos's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. First off good job i was aware about this in .net but i would of never of thought to put in autoit cause i couldnt think it could be done by creating the dummy.zip without doing a byte array. So thank you showing me how to create the dummy file. The script i made uses more shell objects to create browsers to search for the files and folder as seen below i documented best i can put the microsoft links for the objects am using. Only reason i wrote this was show a different way of doing what you did. Basically you got a choice either enter path by using a Input box hit cancel then a browser will pop and you can pick your zip if you want to create one then you will enter the inputbox the path and name of the zip then it will create it. Dim $Shell,$srcFolder,$DestFolder,$items;Objects Const $BIF_BROWSEINCLUDEFILES = 0x4000 Const $ssfPERSONAL = 0x5;My Documents directory $Shell = ObjCreate("Shell.Application") ;$Destfolder = "C:\Backups\tmp.zmp" ;will copy the directory myscripts and everything in it ;if you do c:\myscripts\ then it just copies the directory contents and not myscripts directory ;$srcFolder = "C:\myscripts" $answer = InputBox("Create zip File",'Enter Name of file and path (example."c:\myzip.zip") otherwise hit cancel to browse for zip',"") If @error = 1 then $DestFolder = $shell.browseforfolder(0,"Pick Destination Folder or Zip",$BIF_BROWSEINCLUDEFILES) Else initzip($answer) $Destfolder = $answer EndIF ;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/shell/browseforfolder.asp ;also you can define a default path for the brosweforfolder to open as fourth parameter as so below example ;$DestFolder = $shell.browseforfolder(0,"Pick Destination Folder or Zip",$BIF_BROWSEINCLUDEFILES,$ssfPERSONAL) $srcFolder = $shell.browseforfolder(0,"Pick Source Folder or File",$BIF_BROWSEINCLUDEFILES) ;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/folder/copyhere.asp $Shell.NameSpace($DestFolder).Copyhere ($srcFolder,0) ; DO NOT REMOVE IT NEEDS IT BECAUSE WHEN TRYING TO MOVE FILES TO A ZIP IT CREATES _ ;A NEW PROCESS IF SCRIPTS FINISHES BEFORE COPING STARTS YOU GET A EMPTY ZIP FILE!!!! sleep(5000) Func InitZip ($zip_path_name) If NOT FileExists($zip_Path_name) then $init_zipString= Chr(80) & Chr(75) & Chr(5) & Chr(6);Create the Header String for $n =1 to 18 ;the $init_zipString= $init_zipString & Chr(0);Header next $file =FileOpen($zip_path_name,2) FileWrite($file,$init_zipString) ;Write the string in a file FileClose($file) EndIf EndFunc It just a quick way of creating a zip then adding content to it and i didnt want to waste alot of time creating gui interface for doing the browser so i used was already availably to me not alot of people are aware of browser so this was a perfect example hopefully people can find a use for it. Once again thanks for sharing your findings.
  2. Will Runwait function have the same function as run in regards of the STD I/O streams? Is there any thought in implementing it? Reason am asking is i have a function that calls dir command using run @comspec for searching for a certain file type if found delete and doing enumerating thru each users profiles, but when its finish. It will delete some of the files but not all but if i put msgbox to call path of the file before searching it will delete all of them. An all i can figure is call am making to the Run function not finishing when called again. When i put the msgbox it gives the time it needs to finish? Not sure, but thats what it seems to me. So leads to me first question will runwait have the STD I/O streams?
  3. The reason it failed is because used it wrong below i wrote a example and it works so i hope this can help on what ever your trying to do. $run = "winword.exe"; executable you want to run $args = "path\testfile 01.doc"; arguments $verb = "Open"; other valide functions are edit, print, or just leave it blank $dir = ""; path of executabe can leave blank if it's in the system path, c:\windows\, c:\windows\system32 etc.. $sw = 3; hide = 0, maximize = 3, minimize = 6 $dll = DllOpen("shell32.dll") $ret = Dllcall($dll,"long","ShellExecuteA", _ "hwnd",0, _ "str",$func, _ "str",$run, _ "str",$args, _ "str",$dir, _ "int",$sw) DllClose($dll) thats one way or you can change run to $run = "path\testfile 01.doc and leave $args blank and use defaulted application.
  4. Found out the function for finding out what the default printer only works for xp Per microsoft website for the Win32_Printer WMI. Technet
  5. Hope this helps wrote this last night for a project am working on. It uses WMI for retrieving the data and added some other things to it. I've tested on xp seemed to work didn't have alot time test it on other OS. To use need Beta version for Autoit. Enjoy #include <Array.au3> ;Global Variables Const $wbemFlagReturnImmediately = 0x10 Const $wbemFlagForwardOnly = 0x20 Const $strComputer = "." $count = 0 $sHold = "" $array = "" ;HOW TO USE: ;$ARRAY = Enumprinter() Func EnumPrinter() local $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If $objitem.DeviceID <> "" Then $sHold = $sHold & $objItem.DeviceID & "," $count = $count + 1 Endif Next If $sHold = "" Then Return $sHold else $array = StringSplit($sHold,",") _ArrayDelete($array,$count + 1) _arrayDelete($array,0) Return $array EndIf Endif EndFunc ; HOW TO USE: ; $DefaultPrinter = DefaultPrinter() ; Will return the default printer name if it doesnt have a ; Default printer it will return 0 Func DefaultPrinter() Local $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems ;msgbox(0,"",$Objitem.Default) If $objitem.Default <> 0 Then $result = $objItem.DeviceID ;MsgBox(0,"",$objitem.deviceID) Return $result Endif Next Endif Return 0 EndFunc ;Add A global printer for all profiles ; $default 1=Default use either "" blank statement or 0 Func AddGlobalPrinter($Server,$Printer,$Default) Run(@ComSpec & " /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /ga /n\\" & $Server & "\" & $printer,"",@SW_HIDE) RestartPrintSpool() If $Default = 1 Then ;msgbox(0,"",$printer) SetDefault("\\" & $Server & "\" & $Printer) ;RestartPrintSpool() Elseif $Default = 0 Then Elseif $Default = "" Then EndIF EndFunc ;Remove Printer that was added by AddGlobalPrinter func otherwise if printer ;was installed manual it will fail Func RemoveGlobalPrinter($Server,$Printer) Run(@ComSpec & " /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /gd /n\\" & $Server & "\" & $printer,"",@SW_HIDE) RestartPrintSpool() EndFunc ;Set the Default Printer Func SetDefault($Printer) Run(@ComSpec & " /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n " & $Printer , "",@SW_HIDE) EndFunc ;Helper function for restarting of print spooler Func RestartPrintSpool() local $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Service WHERE Name = 'Spooler'", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems ; msgbox(0,"",$objitem.Name) If $objitem.State = "Running" Then msgbox(0,"",$ObjItem.state) $some = $objItem.StopService() sleep(5000) $some1 = $objItem.StartService() ElseIF $objitem.State = "Stopped" Then ; msgbox(0,"",$ObjItem.state) $ObjItem.StartService() EndIf Next EndIf EndFunc Sorry if its hard to understand like i said i just wrote and didn't spend alot of time cleaning it up. Also put alot of msgbox for testing so i might of missed acouple and will pop up when you it.
×
×
  • Create New...