Jump to content
Davegbuf

Loading Powershell Module to Test Pending Reboots

Recommended Posts

I found a PowerShell module in the TechNet script center that will be useful to me for detecting reboots; however, my knowledge of PowerShell is limited and I don't know how to load the a module for use with my AutoIt scripts. (in case you need it): https://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542)

I loaded the PowerShell module successfully manually via the PowerShell ISE on my test machine, and ran a batch command successfully on it too. NOTE: I sometimes use a batch file commands for troubleshooting a few lines of code and then I convert the "known good" command into my final AutoIt scripts).

As I mentioned, I ran the following batch command-line successfully after I had manually loaded the Powershell module via the ISE (the command  displays a "True" or "False" in the Windows CMD console - see the attachment) :

  • PowerShell -Command (Test-PendingReboot -SkipConfigurationManagerClientCheck).IsRebootPending

I need to know how I can include the PowerShell module in a subfolder and load it, in addition to running the command-line mentioned above. I have used *.PS1 scripts before in my AutoIt projects, but my general knowledge of Powershell is limited and I don't know how to work with modules. Can anyone with some Powershell knowledge help me with these few lines of code needed to accomplish the goal?

I would appreciate any help you can offer.

Successful_PendingReboot_When_PSModule_Loaded_Manually.PNG

Share this post


Link to post
Share on other sites

Should be possible by reading the registry too: https://stackoverflow.com/questions/21789594/check-for-reboot-pending-status-in-vb

#include <AutoItConstants.au3>

Local $sValue = RegRead("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "RebootRequired")
If @error or $sValue <> "*" Then  ; <== Replace "*" with the value you get when a reboot is required
    ConsoleWrite("No reboot required" & @CRLF)
Else
    ConsoleWrite("Reboot required" & @CRLF)
EndIf

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

loading a ps1 and using it:

 

You can use fileinstall if you need the ps1 packaged up with the script.  It would be cooler to write it on the fly tho :)


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Excellent. Thank you very much! I wasn't sure if your example would work because I have a PowerShell module (*.PSM1), and your example had a PowerShell script (*.PS1) but it worked just as well. I noticed that you separated two PowerShell statements with a semicolon ";". That makes sense because I didn't get an error importing the module, but when I tried to run a function on the next line, it looks like the module was not loaded anymore.

I wrote the AutoIt script below for anyone who is interested. The script displays a "True" if the machine is pending a reboot; or "False" if it is not. For other possible functions available in the PowerShell module, take a look at the comments in the pendingreboot.psm1file (I also added them to the end of the AutoIt script) . Download the module from here: https://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542

Note: The AutoIt script below only requires only the fist five characters of data for the strings "Ture" or "False"; however, you will want to comment out the two statements below the "; --- Extract Data and format" remark to display the full text returned by the function, especially if you use it with other functions in the PowerShell module.

 

Enjoy

===============================================

#include <AutoItConstants.au3>
#include <StringConstants.au3>

$sCommands = 'powershell -ExecutionPolicy ByPass import-module ' & @ScriptDir & _
 '\pendingreboot.0.9.0.6\pendingreboot.psm1; (Test-PendingReboot -SkipConfigurationManagerClientCheck).IsRebootPending'
$iPID = Run("cmd /k " & $sCommands, "", @SW_SHOW , $stdout_child)
 ProcessWaitClose($iPID) ; --- Wait for process to complete
 $sOutput=StdoutRead($iPID)

 ; --- Extract Data and format
 $sOutput=StringLeft($sOutput,5)     ; --- Discard white space and extra line of text (CMD path line)
 $sOutput=StringStripWS($sOutput,$STR_STRIPALL) ; --- Strips 5th white space character if the returned value is "True"

MsgBox(0,'Result',$sOutput)

Exit

#cs ============================================================================================
; --- Excerpt Comments from the Powershell module file: pendingreboot.psm1
https://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542

 ===============================================================================================

<#
.SYNOPSIS
    Test the pending reboot status on a local and/or remote computer.

.DESCRIPTION
    This function will query the registry on a local and/or remote computer and determine if the
    system is pending a reboot, from Microsoft/Windows updates, Configuration Manager Client SDK, Pending
    Computer Rename, Domain Join, Pending File Rename Operations and Component Based Servicing.

    ComponentBasedServicing = Component Based Servicing
    WindowsUpdate = Windows Update / Auto Update
    CCMClientSDK = SCCM 2012 Clients only (DetermineifRebootPending method) otherwise $null value
    PendingComputerRenameDomainJoin = Detects a pending computer rename and/or pending domain join
    PendingFileRenameOperations = PendingFileRenameOperations, when this property returns true,
                                  it can be a false positive
    PendingFileRenameOperationsValue = PendingFilerenameOperations registry value; used to filter if need be,
                                       Anti-Virus will leverage this key property for def/dat removal,
                                       giving a false positive

.PARAMETER ComputerName
    A single computer name or an array of computer names.  The default is localhost ($env:COMPUTERNAME).

.PARAMETER Credential
    Specifies a user account that has permission to perform this action. The default is the current user.
    Type a username, such as User01, Domain01\User01, or User@Contoso.com. Or, enter a PSCredential object,
    such as an object that is returned by the Get-Credential cmdlet. When you type a user name, you are
    prompted for a password.

.PARAMETER Detailed
    Indicates that this function returns a detailed result of pending reboot information, why the system is
    pending a reboot, not just a true/false response.

.PARAMETER SkipConfigurationManagerClientCheck
    Indicates that this function will not test the Client SDK WMI class that is provided by the System
    Center Configuration Manager Client.  This parameter is useful when SCCM is not used/installed on
    the targeted systems.

.PARAMETER SkipPendingFileRenameOperationsCheck
    Indicates that this function will not test the PendingFileRenameOperations MultiValue String property
    of the Session Manager registry key.  This parameter is useful for eliminating possible false positives.
    Many Anti-Virus packages will use the PendingFileRenameOperations MultiString Value in order to remove
    stale definitions and/or .dat files.

.EXAMPLE
    PS C:\> Test-PendingReboot

    ComputerName IsRebootPending
    ------------ ---------------
    WKS01                   True

    This example returns the ComputerName and IsRebootPending properties.

.EXAMPLE
    PS C:\> (Test-PendingReboot).IsRebootPending
    True

    This example will return a bool value based on the pending reboot test for the local computer.

.EXAMPLE
    PS C:\> Test-PendingReboot -ComputerName DC01 -Detailed

    ComputerName                     : dc01
    ComponentBasedServicing          : True
    PendingComputerRenameDomainJoin  : False
    PendingFileRenameOperations      : False
    PendingFileRenameOperationsValue :
    SystemCenterConfigManager        : False
    WindowsUpdateAutoUpdate          : True
    IsRebootPending                  : True

    This example will test the pending reboot status for dc01, providing detailed information

.EXAMPLE
    PS C:\> Test-PendingReboot -ComputerName DC01 -SkipConfigurationManagerClientCheck -SkipPendingFileRenameOperationsCheck -Detailed

    CommputerName                    : dc01
    ComponentBasedServicing          : True
    PendingComputerRenameDomainJoin  : False
    PendingFileRenameOperations      : False
    PendingFileRenameOperationsValue :
    SystemCenterConfigManager        :
    WindowsUpdateAutoUpdate          : True
    IsRebootPending                  : True

.LINK

 Background:

https://blogs.technet.microsoft.com/heyscriptingguy/2013/06/10/determine-pending-reboot-statuspowershell-style-part-1/
https://blogs.technet.microsoft.com/heyscriptingguy/2013/06/11/determine-pending-reboot-statuspowershell-style-part-2/
 

Component-Based Servicing:
http://technet.microsoft.com/en-us/library/cc756291(v=WS.10).aspx
 

PendingFileRename/Auto Update:
http://support.microsoft.com/kb/2723674
http://technet.microsoft.com/en-us/library/cc960241.aspx
http://blogs.msdn.com/b/hansr/archive/2006/02/17/patchreboot.aspx
 

CCM_ClientSDK:

http://msdn.microsoft.com/en-us/libr

.NOTES
    Author:  Brian Wilhite
    Email:   bcwilhite (at) live.com
#>

 


#ce ============================================================================================

 

Share this post


Link to post
Share on other sites
3 hours ago, water said:

Should be possible by reading the registry too: https://stackoverflow.com/questions/21789594/check-for-reboot-pending-status-in-vb

#include <AutoItConstants.au3>

Local $sValue = RegRead("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "RebootRequired")
If @error or $sValue <> "*" Then  ; <== Replace "*" with the value you get when a reboot is required
    ConsoleWrite("No reboot required" & @CRLF)
Else
    ConsoleWrite("Reboot required" & @CRLF)
EndIf

 

============================

Thank you but there are many reasons that Windows might be pending a reboot and each is tracked in different places in the registry requiring you to check all of them. My fault for not being more specific with my question. This link shows at least 12 registry keys: https://hiddencodes.wordpress.com/2013/04/24/list-of-registry-keys-involved-in-reboot-pending-decision/

The to check the registry in Windows is not consistent either (thank you Microsoft). Examples from ( https://scriptingetc.wordpress.com/2017/06/16/detect-pending-reboots/) :

Pending Reboot
•HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing
•A reboot is pending if the RebootPending key exists

NOTE: If a reboot is pending then the fill registry path adds the key to the end making it: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending
I didn't know in AutoIt how I would compare a partial tree path since RegRead() reads key values.

Pending Windows Update activity
•HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update
•A reboot is pending if the RebootRequired key exists

Pending File Rename(s)
•HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager ?Key (REG_MULTI_SZ): PendingFileRenameOperations

•A reboot is pending if the value is non-zero / non-empty list of filenames
I had trouble reading these values in AutoIt and I was already frustrated enough to quit for the day

Pending System Renames
•HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName ?Key: ComputerName
•HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName ?Key: ComputerName

•A reboot is pending if the 2 values do not match
NOTE: These are registry keys, not values manes and values. I was not sure how I would compare these in AutoIt

Pending EXE Modification
•HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\UpdateExeVolatile
•Any value indicates a pending reboot

Share this post


Link to post
Share on other sites

let me see the command line where it 'looked like the module wasnt loaded anymore'


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

I see. So the PowerShell approach seems to be the best fit ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
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

  • Similar Content

    • By ur
      I have kept below line to wait for IE to load the site completely and continue.
      _IELoadWait($oIE)
       
      But, the code is continuing without waiting for it and I my execution is failing as the elements are not loaded completely.

       
      Any suggestions for alternate code to wait for the browser to load completely?
       
    • By Razraal
      Hey there folks!
      Task:
      I have an array of DllStructs, created with the function DllStructCreate. Let's call the array $structs. This $structs contains important information for the program. I want to save my  $structs variable for future use in a file (i.e.: the user closes the program, opens it again and has the option to load a file). I want to load files which contain a $structs variable, and let the program work with this "loaded" variable. Questions:
      Since I have never done such a thing (saving/loading a file, possibly in a different format from txt or ini), I'd like to know:
      Is this possible? Is my only option to save my $structs in text format? That would require a function which receives a file and interprets the text it has, creating a new $structs with the info it's getting from the file. (I think this could lead to trouble) I'm worried about security. Since the program will be loading files, I don't want it to crash because the user decided to give it modified files. Is it possible to create a file that's readonly for the user? That would prevent some tampering with the file. From what I've been reading, I have several functions available for File management, namely FileOpen, FileRead and FileWrite. In a first glance, these appear to be the only functions I need. Do I need more?  
      Thank you for your time!
      Cheers!
    • By madmega
      Hi, i have some sort of problem here, from a website i can download a xls file, it is 180kb, when i open it with excel and then save it (without changing anything), the file is 130kb.

      Is there a possibility to resave a xls file, without opening excel to do it ?
    • By wakillon
      For more details go to the Topic
    • By Decipher
      I updated the UDF by Patric Pendelin to use the MemoryDLL UDF.
      There are only two new functions: _SevenZip_Load & _SevenZip_Free
      The first function must be called before using any other functions included in the UDF and the other should be called to free memory when the UDF is no longer needed!
      The size of binary from the module was excessive so I used the ZLMA UDF to compress it. It will be decompressed at run time before its loaded into memory.
      The only advantage of using this UDF is that it removes the need to included any DLLs in your script.
      A lot of functions haven't been added yet!
      For those that dare: The API for the 7-Zip32.dll module is included in the attachment.
      These functions work in the same way you would you use the standalone 7za.exe executable so the Help.chm file applies to these functions aswell.
      Thats it, Enjoy!
      The code below is a sneak peak at the actually UDF, meaning it dosen't work without the other includes and the embed binary. - Download the attachment.
      #include-once #include "MemoryDLL.au3" #include "LZMA.au3" Global $__7ZIPDLL = Default, $__7ZIPINIT = False #cs =============================================================================== Name: 7-Zip.au3 Version: 1.0 Datum: 08.07.2008 Author: Patric Pendelin eMail: <patric.pendelin (a) gmx.de> Modified By: Decipher Script Function: _SevenZip_Load() _SevenZip_Extract($s_Archive, $s_Out="", $s_Pass="", $szCmdLine="", $s_Overwrite="", $hwnd=0, $szOutput="NULL", $dwSize=0) Extracts files from an archive _SevenZip_Add($s_Archive, $s_Out = "", $s_Typ = "7z32", $i_Comp = 5, $s_Pass = "", $szCmdLine = "", $hwnd = 0, $szOutput = "NULL", $dwSize = 0) Add files to an archive _SevenZip_GetVersion() Get 7_zip32.dll Version _SevenZip_GetRunning() _SevenZip_CheckArchive($s_Archive, $i_iMode = 0) _SevenZip_GetArchiveType($s_Archive) _SevenZip_GetFileCount($s_Archive) _SevenZip_GetUDFVersion() Returns UDF version number _SevenZip_Free() #ce =============================================================================== Func _SevenZip_Load() If Not $__7ZIPINIT Then $__7ZIPDLL = MemoryDllOpen(__7ZIPBIN()) $__7ZIPINIT = True EndIf EndFunc Func _SevenZip_Free() If $__7ZIPINIT Then MemoryDllClose($__7ZIPDLL) $__7ZIPINIT = False $__7ZIPDLL = Default EndIf EndFunc ;=============================================================================== ; Function Name: _SevenZip_Extract ; Description: Extracts files from an archive ; ; Parameter(s): $s_Archive: Fullpath to Archive-File ; $s_Out: Specifies a destination directory where files are to be extracted. (Def. "") ; $s_Pass: Specifies password. (Def. "") ; $szCmdLine: Command Line Commands. (Def. "") ; $s_Overwrite: Specifies the overwrite mode during extraction, to overwrite files already present on disk. (Def. "") ; -1: Overwrite All existing files without prompt. ; -2: Skip extracting of existing files. ; -3: aUto rename extracting file (for example, name.txt will be renamed to name_1.txt). ; -4: auto rename existing file (for example, name.txt will be renamed to name_1.txt). ; $hwnd: The window handle of the application which calls 7-zip32.dll. (Def. 0) ; $szOutput: The buffer because 7-zip32.dll returns the result. (Def. "NULL") ; $dwSize: Größe des Puffers. When the result exceeds designated size, it is economized in this size. ; If size is 1 or more, always NULL letter is added lastly. (Def. 0) ; ; Syntax: _SevenZip_Extract($s_Archive, $s_Out="", $s_Pass="", $szCmdLine="", $s_Overwrite="", $hwnd=0, $szOutput="NULL", $dwSize=0) ; Return Value(s): On Success -Return 1 ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_Extract($s_Archive, $s_Out = "", $s_Pass = "", $szCmdLine = "", $s_Overwrite = "", $hwnd = 0, $szOutput = "NULL", $dwSize = 0) ; Set Output directory If $s_Out = "" Then Local $as_Res = StringSplit($s_Archive, "\") For $i = 1 To $as_Res[0] - 1 $s_Out &= $as_Res[$i] & "\" Next EndIf ; (Overwrite mode) switch: If $s_Overwrite = 1 Then $s_Overwrite = "-aoa"; Overwrite All existing files without prompt. ElseIf $s_Overwrite = 2 Then $s_Overwrite = "-aos"; Skip extracting of existing files. ElseIf $s_Overwrite = 3 Then $s_Overwrite = "-aou"; Auto rename extracting file (for example, name.txt will be renamed to name_1.txt). ElseIf $s_Overwrite = 4 Then $s_Overwrite = "-aot"; Auto rename existing file (for example, name.txt will be renamed to name_1.txt). EndIf If $szCmdLine = "" Then $szCmdLine = ' x "' & $s_Archive & '" ' & $s_Overwrite & ' -o"' & $s_Out & '" -p"' & $s_Pass & '"' Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZip", "hwnd", $hwnd, "str", $szCmdLine, "str", $szOutput, "int", $dwSize) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_Extract ;=============================================================================== ; Function Name: _SevenZip_Add ; Description: Extracts files from an archive ; ; Parameter(s): $s_Archive: Fullpath to Archive-File ; $s_Out: Specifies a destination directory where files are to be extracted. (Def. "") ; $s_Typ: Specifies the type of archive. ; $i_Comp: Sets level of compression. [0 | 1 | 3 | 5 | 7 | 9 ] ; $s_Pass: Specifies password. (Def. "") ; $szCmdLine: Command Line Commands. (Def. "") ; $hwnd: The window handle of the application which calls 7-zip32.dll. (Def. 0) ; $szOutput: The buffer because 7-zip32.dll returns the result. (Def. "NULL") ; $dwSize: Größe des Puffers. When the result exceeds designated size, it is economized in this size. ; If size is 1 or more, always NULL letter is added lastly. (Def. 0) ; ; Syntax: _SevenZip_Add($s_Archive, $s_Out = "", $s_Typ = "7z32", $i_Comp = 5, $s_Pass = "", $szCmdLine = "", $hwnd = 0, $szOutput = "NULL", $dwSize = 0) ; Return Value(s): On Success -Return 1 ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_Add($s_Archive, $s_Out = "", $s_Typ = "7z32", $i_Comp = 5, $s_Pass = "", $szCmdLine = "", $hwnd = 0, $szOutput = "NULL", $dwSize = 0) If $szCmdLine = "" Then If $s_Pass = "" Then $szCmdLine = '-t' & $s_Typ & ' a "' & $s_Archive & '" "' & $s_Out & '" -mx=' & $i_Comp Else $szCmdLine = '-t' & $s_Typ & ' a "' & $s_Archive & '" "' & $s_Out & '" -p"' & $s_Pass & '" -mhe=on -mx=' & $i_Comp EndIf EndIf Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZip", "hwnd", $hwnd, "str", $szCmdLine, "str", $szOutput, "int", $dwSize) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_Add ;=============================================================================== ; Function Name: _SevenZip_GetVersion ; Description: The version of 7-zip32.dll is returned. ; ; Parameter(s): None. ; ; Syntax: _SevenZip_GetVersion() ; Return Value(s): On Success -Return File Version ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_GetVersion() Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipGetVersion") Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_GetVersion ;=============================================================================== ; Function Name: _SevenZip_GetRunning ; Description: Whether or not presently 7-zip32.dll while operating, you obtain. ; Application side before executing API which by all means accompanies file access such as compressing/thawing, ; it is necessary to check whether because of this feasibility. ; ; Parameter(s): None. ; ; Syntax: _SevenZip_GetRunning() ; Return Value(s): On Success -Return 1(It is in the midst of executing.) ; Return 0(Is not in the midst of executing, (feasibility).) ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_GetRunning() Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipGetRunning") Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_GetRunning ;=============================================================================== ; Function Name: _SevenZip_CheckArchive ; Description: Whether or not presently 7-zip32.dll while operating, you obtain. ; As the archive file which the designated file supports ; It returns whether or not it is correct. ; ; Parameter(s): $s_Archive: Fullpath to Archive file ; ; Syntax: _SevenZip_CheckArchive($s_Archive) ; Return Value(s): On Success -Return 1 (At the time of correct archive file.) ; Return 0 (When the file is illegitimate.) ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_CheckArchive($s_Archive, $i_iMode = 0) Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipCheckArchive", "str", $s_Archive, "int", $i_iMode) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_CheckArchive ;=============================================================================== ; Function Name: _SevenZip_GetArchiveType ; Description: Type of the archive file ; ; Parameter(s): $s_Archive: Fullpath to Archive file ; ; Syntax: _SevenZip_GetArchiveType($s_Archive) ; Return Value(s): On Success -Return 1 (ZIP type) ; Return 2 (7z32 type) ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_GetArchiveType($s_Archive) Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipGetArchiveType", "str", $s_Archive) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_GetArchiveType ;=============================================================================== ; Function Name: _SevenZip_GetFileCount ; Description: Type of the archive file ; ; Parameter(s): $s_Archive: The number of files in the Archive file. ; ; Syntax: _SevenZip_GetFileCount($s_Archive) ; Return Value(s): On Success -Return Numer of files ; On Failure -@error 1: Can´t opens a DLL file for use in MemoryDllCall. ; @error 2: Error in MemoryDllCall ; ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_GetFileCount($s_Archive) Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipGetFileCount", "str", $s_Archive) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_GetFileCount #region ### BINARY ### Func __7ZIPBIN() #cs Name: 7-ZIP32 BINARY Version 9.20.00.02 Requirements: Windows9x/Me/NT/200x/XP/Vista/7 Author: Akita Minoru ( Http://Akky.Xrea.Jp/support.Html ) Download the Library: 7-Zip-Library.7z
      Basic Usage:
      #include "7-Zip.au3" _SevenZip_Load() Dim $sCommandLine = "Accepts Switches and etc" _SevenZip_Exec($sCommandLine) ; See the included 7-Zip.chm documentation _SevenZip_Free() Exit
×
×
  • Create New...