Jump to content











Photo
- - - - -

Install a Network layer after PENetwork, drvload.exe and drvinst.exe

firebwall winpkfilter network firewall

  • Please log in to reply
13 replies to this topic

#1 Aeolis

Aeolis

    Frequent Member

  • .script developer
  • 145 posts
  • Location:Rio de Janeiro
  • Interests:I am just trying to learn and help.
  •  
    Brazil

Posted 14 April 2012 - 08:24 PM

Hello folks,

I have been working on a firewall for PE script based on fireBwall (http://firebwall.com/index.php). It's installation is fairly simply and I've managed to almost finish the script, but I am facing a hard to deal problem. The problem is:

fireBwall need that WinpkFilter driver to be installed on PE before it runs. It's fairly simple to be done we just need to run a CMD with this command lines snetcfg_x86.exe -v -l ndisrd_lwf.inf -c s -i nt_ndisrd

I have successfully done its installation and run fireBwall manually after PE finishes the boot and driver loading, but the automation of this process has been killing me!

I have tried a bat file approach and a vbs file approach through the AddPostConfig,"Start fireBwall","%PE_Programs%\%ProgramFolder%\WinpkFilter\Install.bat",,2

The problem is that the bat or vbs script must wait until the PENetwork finishes its boot job as well as drvload must not be running and drvinst must not be running.

I have took a look at Homes32 WinPcap script because WinpkFilter share some similarities regarding its way of installation, but it did not helped me much.

Please, I need ideas, suggestions, hints, anything.

Best regards,

Aeolis

Attached File  Install.bat   1.58KB   6 downloads

#2 Holger

Holger

    Silver Member

  • .script developer
  • 534 posts
  • Location:Munich
  • Interests:- programming / scripting
    - scooter driving / modifying
    - writing poems
  •  
    Germany

Posted 14 April 2012 - 11:48 PM

You could for instance add an additional command in your "PENetwork.ini" with the internal editor or manually:

[PENetwork]

...

[ProfileXYZ]

...

CMDStart.CMD1=snetcfg_x86.exe -v -l ndisrd_lwf.inf -c s -i nt_ndisrd

CMDStart.Start1=hidden

CMDStart.Wait1=No

...




This command will be executed after PENetwork finishes all things so far.

#3 Aeolis

Aeolis

    Frequent Member

  • .script developer
  • 145 posts
  • Location:Rio de Janeiro
  • Interests:I am just trying to learn and help.
  •  
    Brazil

Posted 15 April 2012 - 11:38 AM

Hello folks,

Dear Holger thank you for you answer. The idea is good I will give it a try. Holger this approach you suggest me is a generic one? I mean would it fit a WinXP, WinVista and Win7 project?

The current approach I am using is to use a .bat file with the following:


REM @ECHO OFF
CD /d %~dp0
SLEEP 10
:CHECK
ECHO CHECKING IF DRVINST IS RUNNING...
TASKLIST /FI "IMAGENAME EQ drvinst.exe" 2>NUL | FIND /I /N "drvinst.exe" >NUL
IF %ERRORLEVEL% EQU 0 GOTO DRVINST_IS_RUNNING
IF %ERRORLEVEL% NEQ 0 GOTO DRVINST_IS_NOT_RUNNING

:DRVINST_IS_RUNNING
ECHO DRVINST IS RUNNING. WAITING...
SLEEP 3
GOTO CHECK

:DRVINST_IS_NOT_RUNNING
ECHO DRVINST IS NOT RUNNING.

:CHECK_INTERNET
ECHO CHECKING INTERNET CONNECTION...

:FIRST_CHECK
ECHO FIRST CHECK...
SLEEP 5
PING -n 1 127.0.0.1
IF %ERRORLEVEL% EQU 0 GOTO SECOND_CHECK
IF %ERRORLEVEL% NEQ 0 GOTO CHECK_INTERNET

:SECOND_CHECK
ECHO SECOND CHECK...
SLEEP 5
PING -n 1 www.google.com
IF %ERRORLEVEL% EQU 0 GOTO CONNECTION_OK
IF %ERRORLEVEL% NEQ 0 GOTO CHECK_INTERNET
:CONNECTION_OK
ECHO INTERNET CONNECTION OK...

:INSTALLING
ECHO INSTALLING...
REM snetcfg_x86.exe -v -l ndisrd.inf -m ndisrd_m.inf -c s -i nt_ndisrd
snetcfg_x86.exe -v -l ndisrd_lwf.inf -c s -i nt_ndisrd
IF %ERRORLEVEL% EQU 0 GOTO WAIT
IF %ERRORLEVEL% NEQ 0 GOTO CHECK
:WAIT
SLEEP 10
:CHECK_INTERNET_AGAIN
ECHO CHECKING INTERNET CONNECTION...

:FIRST_CHECK_AGAIN
ECHO FIRST CHECK...
SLEEP 5
PING -n 1 127.0.0.1
IF %ERRORLEVEL% EQU 0 GOTO SECOND_CHECK_AGAIN
IF %ERRORLEVEL% NEQ 0 GOTO CHECK_INTERNET_AGAIN

:SECOND_CHECK_AGAIN
ECHO SECOND CHECK...
SLEEP 5
PING -n 1 www.google.com
IF %ERRORLEVEL% EQU 0 GOTO CONNECTION_OK_AGAIN
IF %ERRORLEVEL% NEQ 0 GOTO CHECK_INTERNET_AGAIN
:CONNECTION_OK_AGAIN
ECHO INTERNET CONNECTION OK...
START Y:\Programs\fireBwall\fireBwall.exe
GOTO END
:END
EXIT

Best regards,

Aeolis

#4 RoyM

RoyM

    Frequent Member

  • .script developer
  • 420 posts
  • Interests:"Booting and Owning".
  •  
    United States

Posted 15 April 2012 - 04:40 PM

Hi Aeolis
(this approach you suggest me is a generic one? )
Holgers suggestion was also the first resolve that came to my mind.

Your batch seems sound, does it work as intended ?
I'm sure Mr. Wonko could give you some more pointers.
a.k.a "The Finder"/ "batch guru"

If you are going to release fireBwall.script
In order to ease the burden on the noobies,
so they don't have to manualy edit PeNetwork.
What about calling PeNetwork from your batch first,
then continue processing.

Not sure what you mean by this.
(I mean would it fit a WinXP, WinVista and Win7 project?)

Does fireBwall work with all of these PE's ?
RoyM

#5 Aeolis

Aeolis

    Frequent Member

  • .script developer
  • 145 posts
  • Location:Rio de Janeiro
  • Interests:I am just trying to learn and help.
  •  
    Brazil

Posted 15 April 2012 - 05:49 PM

Hello folks,

@RoyM: fireBwall AFAIK works on XP, Vista and 7. I have tested it under Win7PE_SE. When I asked for a generic solution I meant a solution that fits several PE projects. I don't know if PENetwork is a widespread component on all PE projects. In case PENetwork is not common to all PE projects I could not build my solution on it. Got it? The part of automatically create a profile for PENetwork is not a newbie task, so that is an extra problem. For now, I don't know how to automate this task.

The batch file worked under Win7PE_SE, but I would like to make it smaller, smarter, faster and more reliable. So any ideas or suggestions?

Best regards,

Aeolis

#6 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 15 April 2012 - 06:50 PM

You could for instance add an additional command in your "PENetwork.ini" with the internal editor or manually:
[PENetwork]
...
[ProfileXYZ]
...
CMDStart.CMD1=snetcfg_x86.exe -v -l ndisrd_lwf.inf -c s -i nt_ndisrd
CMDStart.Start1=hidden
CMDStart.Wait1=No
...


This command will be executed after PENetwork finishes all things so far.


I would also recommend this approach as it is the simplest.
but you could also use a more complicated but more flexable way as I did when I wrote my BGInfo script. I needed to wait until penetwork, etc was finished before launching bginfo so network info could be correctly displayed. (penetwork's CMDStart feature was broken at the time) and it also works with other projects that may use The Turth's penetcfg.exe instead of Holger's penetwork.exe

I solved the problem with a simple autoit script that should be easily adaptable for your situation and take the place of your batch file.
it waits for all specified processes to exit and then runs the program. It may need some tweaking but should give you a good starting point.


#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_icon=main.ico

#AutoIt3Wrapper_outfile=RunfireBwall.exe

#AutoIt3Wrapper_Res_Comment=This program is freeware and is distributed AS IS without any warrenty expressed or implied.

#AutoIt3Wrapper_Res_Description=Launcher for fireBwall

#AutoIt3Wrapper_Res_Fileversion=1.0.0.0

#AutoIt3Wrapper_Res_LegalCopyright=

#AutoIt3Wrapper_Res_Language=1033

#AutoIt3Wrapper_Res_Field=Compile Date|%longdate%, %time%

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;#NoTrayIcon

;

; AutoIt Version: 3.3.8.0

; Language:	   English

; Platform:	   Windows

; Author:		 Jonathan Holmgren (Homes32) (jonathan@swanrivercomputers.com)

;

; Script Function:

;   Launcher for fireBwall

;

; License: This program is distributed as freeware in the hope that it will be usefull but without any warrenty

;		  expressed or implied. You are free to modify this script but I would appriciate it if you shared your

;		  changes with me and don't take credit for work you did not do.

;

; Last Modifed 04/04/2012

;

; Changlog:

; v1.0.0 - 04/15/2012 - Initial Release

; Directives

#include <GuiToolTip.au3>

; Globals

Global Const $ProgramName = "fireBwall Launcher"

Global Const $ProgramVersion = "1.0.0"



; Program Entry Point

PreStart() ; wait 1m or until process PENetwork/penetcfg finish

ShellExecute("snetcfg_x86.exe", "-v -l ndisrd_lwf.inf -c s -i nt_ndisrd", @ScriptDir, "open", @SW_HIDE) ; install the WinpkFilter driver

; place any other processing you need here....

; Finished!

; ===============================================================================================================

; Below this line live the functions

; ===============================================================================================================

; ===============================================================================================================

; Function:    PreStart()

; Description: Wait for network process to finish so we can get the IP address info.

; Usage:	   PreStart()

; ===============================================================================================================

Func PreStart()

Local $diff, $secondsRem, $minutes, $Countdown

Local $ms = 60000 ; timout value in milliseconds.

Local $timer = TimerInit()

Local $GWL_STYLE = -16 ; Used with GetWindowLong() to retrieve the window styles.

Local $Programs[4] ; Array of programs to wait for

$Programs[0] = "PENetwork.exe"

$Programs[1] = "penetcfg.exe"

$Programs[2] = "drvload.exe"

$Programs[3] = "drvinst.exe"

; try and locate the system tray and pick our position

$aTipLoc = _Toast_Locate(245, 55) ; approx width and height of tip

ToolTip("Starting BGInfo", $aTipLoc[0], $aTipLoc[1], "Starting " & $ProgramName & "...", 1, 0)

Local $hToolTip = WinGetHandle("[TITLE:Starting BGInfo; CLASS:tooltips_class32]", "") ; Text is Title for a tooltip

_WinAPI_SetWindowLong($hToolTip, $GWL_STYLE, BitOR(_WinAPI_GetWindowLong($hToolTip, $GWL_STYLE), $TTS_CLOSE)) ; put [X] on tip

; wait for network programs to finish so we can display the IP address.

For $i = 0 To UBound($Programs) - 1 Step 1

  If ProcessExists($Programs[$i]) Then

   ;wait for timer to expire

   While TimerDiff($timer) < $ms

    ; TimerDiff doesn't seem to work good with qEmu and gives strange results -- seems to be CPU related

    ; as a result when running this program in qemu the timer doesn't give correct results so BGInfo won't

    ;   be run until the program (penetwork, etc.) actually quits.

    ; related problems threads:

    ;   http://www.autoitscript.com/forum/index.php?showtopic=115612

    ;   http://www.autoitscript.com/trac/autoit/ticket/1082

    ;   http://www.autoitscript.com/forum/index.php?showtopic=105761

    $seconds = TimerDiff($timer) / 1000

    $diff = $seconds - ($ms / 1000)

    $minutes = Int($diff / 60) * - 1

    $secondsRem = ($diff - ($minutes * 60)) * - 1

    $Countdown = StringFormat("%02d", $minutes) & ":" & StringFormat("%02d", $secondsRem)

    Sleep(500) ; reduce flicker

    _GUIToolTip_UpdateTipText($hToolTip, 0, 0, "Waiting " & $Countdown & " for " & $Programs[$i] & " to finish.")

    If Not ProcessExists($Programs[$i]) Then ExitLoop ; see if process terminated before timeout reached

   WEnd

  EndIf

Next

;tooltip is hidden, not closed on [X] click

If _GUIToolTip_ToolExists($hToolTip) Then _GUIToolTip_Destroy($hToolTip)

EndFunc   ;==>PreStart



; #INTERNAL_USE_ONLY#============================================================================================================

; Name...........: _Toast_Locate

; Description ...: Find Systray and determine Toast start position

; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height)

; Parameters ....: $iToast_Width  - required width of slice

;				  $iToast_Height - required height of slice

; Author ........: Melba23, based on some original code by GioVit

; Modified.......: Homes32 adapted for use in this script. (RunBgInfo.exe)

; Remarks .......:

; ===============================================================================================================================

Func _Toast_Locate($iToast_Width, $iToast_Height)

; Define return array

Local $aToast_Data[3]

; Find systray

Local $iPrevMode = Opt("WinTitleMatchMode", 4)

Local $aTray_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")

Opt("WinTitleMatchMode", $iPrevMode)

; If error in finding systray

If Not IsArray($aTray_Pos) Then

  ; try and estimate where the tray is

  Local $aTray_Pos[4]

  $aTray_Pos[0] = -2

  $aTray_Pos[1] = @DesktopHeight - 30

  $aTray_Pos[2] = @DesktopWidth

  $aTray_Pos[3] = 30

EndIf

; Determine direction of Toast motion and starting position

If $aTray_Pos[1] > 0 Then ; bottom

  $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10

  $aToast_Data[1] = $aTray_Pos[1] - $iToast_Height

ElseIf $aTray_Pos[0] > 0 Then ; right

  $aToast_Data[0] = $aTray_Pos[0] - $iToast_Width

  $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10

ElseIf $aTray_Pos[2] = @DesktopWidth Then ; top

  $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10

  $aToast_Data[1] = $aTray_Pos[1] + $aTray_Pos[3]

ElseIf $aTray_Pos[3] = @DesktopHeight Then ; left

  $aToast_Data[0] = $aTray_Pos[0] + $aTray_Pos[2]

  $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10

EndIf

Return $aToast_Data

EndFunc   ;==>_Toast_Locate

;EOF



#7 RoyM

RoyM

    Frequent Member

  • .script developer
  • 420 posts
  • Interests:"Booting and Owning".
  •  
    United States

Posted 15 April 2012 - 07:20 PM

"Yes, Got it", very cool it works under all PE's

PeNetwork is usually common to most Winbuilder PE's, albeit different versions may exist.
so calling PeNetwork from batch, ( No matter which version ) should do the trick.
Have your script check for existence of PeNetwork,
(pseudo code) IF NOTEXIST PeNetwork.exe, Message,"PeNetwork Not Found",5

As Homes32 said, PeNetwork would be the simplest and easiest to implement.
BTW, nice little script there Homes32.

If you don't want to use PeNetwork,
There are also the options:

startnet.cmd
OR

Wpeinit with an autounattend.xml
the autounattend.xml can set all network options.
I have a script you can look at for ideas,
my script will write the autounattend for you and set all network settings
based on settings input to the script interface.

Screen Resolution, Color Depth, Refresh Rate, DPI,
Static or DHCP IPv4/6, DHCP Server, DNS Suffix Search List,
IPv4/6 Gateway, IPv4/6 DNS Server, Wins Server,
Computername, User, Password, NetworkLocation/WORKGROUP, Network Shares/Map Drive,
Enable/Disable Firewall, Start Services, Run .cmd before or after, Etc, Etc.
Anything that an autounattend.xml can do.

Wpeinit is a command-line tool that initializes Windows PE each time it boots.
When Windows PE starts, Winpeshl.exe executes Startnet.cmd, which launches Wpeinit.exe.
Wpeinit.exe specifically installs PnP devices, processes Unattend.xml settings, and loads network resources.
Wpeinit replaces the initialization function previously supported in Factory.exe -winpe.
Wpeinit outputs a log messages to c:Windowssystem32wpeinit.log.

You can manually execute Wpeinit from a Windows PE Command Prompt window to process a custom answer file.
Wpeinit.exe accepts one option called -unattend. You can specify the parameter in one of four ways.
%SystemRoot%System32wpeinit.exe /unattend=%SystemRoot%System32autounattend.xml

OR

wpeutil.exe with the flag "InitializeNetwork" will "load networking support and PnP drivers,"
wpeutil InitializeNetwork
Initializes network components and drivers, and sets the computer
name to a randomly-chosen value.

Additionaly
There are other options to start network, one that comes to mind
is a chinese app, ( the name escapes me now ) but I recall that Dera
used it in one of his scripts and also posted info on reboot.
However you may need to brush-up on your chinese.

"Is that the penetcfg.exe I'm thinking of Homes32 ?"

RoyM

#8 Aeolis

Aeolis

    Frequent Member

  • .script developer
  • 145 posts
  • Location:Rio de Janeiro
  • Interests:I am just trying to learn and help.
  •  
    Brazil

Posted 15 April 2012 - 07:21 PM

Hello folks,

I have looked after PENetwork profiles solution although its really simpler its very complicated at the same time. PENetwork can easily run the necessary commands, but how could make fireBWall script interacts and automatically right the necessary profile information on PENetwork script? And how could I do that for the alternative The Turth's penetcfg.exe as homes32 mentioned?

The Autoit solution is far beyond my skills right now. Maybe when I get a better scripter I could try this one. Thank you homes32, but I pass this one for now.

The bat file approach is working, but I don't think it's clean or reliable enough for now (I think its is a bit clumsy right now). I will wait for Wonko as suggested by RoyM.

Thank you all for your help.

Best regards,

Aeolis

#9 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 15 April 2012 - 07:49 PM

Additionaly
There are other options to start network, one that comes to mind
is a chinese app, ( the name escapes me now ) but I recall that Dera
used it in one of his scripts and also posted info on reboot.
However you may need to brush-up on your chinese.

"Is that the penetcfg.exe I'm thinking of Homes32 ?"

RoyM


I believe you are referring to pecmd.exe a very powerful and advanced tool but unfortunately very little English documentation and forums are all Chinese

I was referring to PeNetCfg.exe coded by The Truth (he is also the author of PEShell.exe used by many current projects as the shell loader/swapper)
It is the base of network support in most BartPE based projects but also works fine in most pe projects here, although most prefer Holger's program for its versatility and wireless network support.

The Autoit solution is far beyond my skills right now. Maybe when I get a better scripter I could try this one. Thank you homes32, but I pass this one for now.

no worries. I know its an advanced solution, but one that has worked well for my needs in solving a problem similar to yours.
If you ever feel like giving it a whirl and get stuck I'll try and help best I can. its not as complicated as it looks and can get even simpler if we take out the tooltip gui/countdown and run silent.
if you want to see how it works in practice just look at the BGInfo script included in Win7PE_SE.

#10 RoyM

RoyM

    Frequent Member

  • .script developer
  • 420 posts
  • Interests:"Booting and Owning".
  •  
    United States

Posted 15 April 2012 - 07:53 PM

I believe you are referring to pecmd.exe a very powerful and advanced tool but unfortunately very little English documentation and forums are all Chinese

Yes, That's the one. Thanks

RoyM

#11 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 15 April 2012 - 08:06 PM

for reference here is the cut down version without all the visual feedback. gets you down to about 19 lines of actual code.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_Icon=main.ico

#AutoIt3Wrapper_Outfile=RunfireBwall.exe

#AutoIt3Wrapper_Res_Comment=This program is freeware and is distributed AS IS without any warrenty expressed or implied.

#AutoIt3Wrapper_Res_Description=Launcher for fireBwall

#AutoIt3Wrapper_Res_Fileversion=1.0.0.0

#AutoIt3Wrapper_Res_Language=1033

#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker

#AutoIt3Wrapper_Res_Field=Compile Date|%longdate%, %time%

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;#NoTrayIcon

;

; AutoIt Version: 3.3.8.0

; Language:	   English

; Platform:	   Windows

; Author:		 Jonathan Holmgren (Homes32) (jonathan@swanrivercomputers.com)

;

; Script Function:

;   Launcher for fireBwall - NO TOOLTIP FEEDBACK

;

; License: This program is distributed as freeware in the hope that it will be usefull but without any warrenty

;		  expressed or implied. You are free to modify this script but I would appriciate it if you shared your

;		  changes with me and don't take credit for work you did not do.

;

; Last Modifed 04/04/2012

;

; Changlog:

; v1.0.0 - 04/15/2012 - Initial Release

; Program Entry Point

PreStart() ; wait 1m or until process PENetwork/penetcfg finish

ShellExecute("snetcfg_x86.exe", "-v -l ndisrd_lwf.inf -c s -i nt_ndisrd", @ScriptDir, "open", @SW_HIDE) ; install the WinpkFilter driver

; place any other processing you need here....

; Finished!

; ===============================================================================================================

; Function:	PreStart()

; Description: Wait for process to finish before we continue with the script.

; Usage:	   PreStart()

; ===============================================================================================================

Func PreStart()

Local $ms = 60000 ; timout value in milliseconds. you can ajust this if you would like to wait longer for programs to finish.

Local $timer = TimerInit()

Local $Programs[4] ; Array of programs to wait for

$Programs[0] = "PENetwork.exe"

$Programs[1] = "penetcfg.exe"

$Programs[2] = "drvload.exe"

$Programs[3] = "drvinst.exe"

; wait for network programs to finish so we can display the IP address.

For $i = 0 To UBound($Programs) - 1 Step 1

  If ProcessExists($Programs[$i]) Then

   ;wait for timer to expire

   While TimerDiff($timer) < $ms

	If Not ProcessExists($Programs[$i]) Then ExitLoop ; see if process terminated before timeout reached

   WEnd

  EndIf

Next

EndFunc   ;==>PreStart

;EOF



#12 RoyM

RoyM

    Frequent Member

  • .script developer
  • 420 posts
  • Interests:"Booting and Owning".
  •  
    United States

Posted 15 April 2012 - 08:29 PM

Here is How to interact with other scripts:

I was going to suggest looking at VBox Guest Additions.script
in Downloads section, but I can't seem to find it right now.
Forum Upgrade Issue I assume.

VirtualBox Guest Additions v4.1.8r75467

In this script, I write settings to:
C:Win7PE_SE_2011_05_20ProjectsWin7PE_SEVirtualTestVirtualBox.script

Here are some snippets
pButtonAddToVBox == Writes settings to VirtualBox.script
pButtonRemoveVBox == Removes settings to VirtualBox.script

The best way to do it, is to use a common line in the script,
in this case I used this line: Retrieve,FileSize,%ISOfileVar%,%sizeISO%
which should always be in the script, no matter what version or update is used.

[pButtonAddToVBox]
// First check to make sure the script exists
If,ExistFile,%ProjectDir%VirtualTestVirtualBox.script,Begin

// Show a simple message box
Message,"Adding SharedFolder to VirtualBox.script",INFORMATION,2

// If I have already added/modified VirtualBox.script, delete the added lines
TXTDelLine,%ProjectDir%VirtualTestVirtualBox.script,"ShellExecute#$cHide#$c#$pVBoxManage#$p#$c#$qsharedfolder add"
TXTDelLine,%ProjectDir%VirtualTestVirtualBox.script,"TxtAddLine#$c#$pDebugCmd#$p#$c#$qVBoxManage.exe sharedfolder add"

## Now replace:
// Retrieve,FileSize,%ISOfileVar%,%sizeISO%
## With:
// ShellExecute,Hide,%VBoxManage%,"sharedfolder add %VBoxName% --name %VBoxShareFolderName% --hostpath %VBoxShareFolderPath%"
// TxtAddLine,%DebugCmd%,"VBoxManage.exe sharedfolder add %VBoxName% --name %VBoxShareFolderName% --hostpath %VBoxShareFolderPath%",Append
// Retrieve,FileSize,%ISOfileVar%,%sizeISO%

## Note the #$x is the important part
TXTReplace,%ProjectDir%VirtualTestVirtualBox.script,"Retrieve#$cFileSize#$c#$pISOfileVar#$p#$c#$psizeISO#$p","ShellExecute,Hide,%VBoxManage%,#$qsharedfolder add %VBoxName% --name %VBoxShareFolderName% --hostpath %VBoxShareFolderPath%#$q#$xTxtAddLine#$c%DebugCmd%#$c#$qVBoxManage.exe sharedfolder add #$pVBoxName#$p --name %VBoxShareFolderName% --hostpath %VBoxShareFolderPath%#$q#$cAppend#$xRetrieve#$cFileSize#$c%ISOfileVar%#$c%sizeISO%"

End
If,NotExistFile,%ProjectDir%VirtualTestVirtualBox.script,Message,"%ProjectDir%VirtualTestVirtualBox.script#$x Script not found, not modified",INFORMATION,5
//


## This one only removes the added entries
[pButtonRemoveVBox]
If,ExistFile,%ProjectDir%VirtualTestVirtualBox.script,Begin
Message,"Removing SharedFolder from VirtualBox.script",INFORMATION,2
TXTDelLine,%ProjectDir%VirtualTestVirtualBox.script,"ShellExecute#$cHide#$c#$pVBoxManage#$p#$c#$qsharedfolder add"
TXTDelLine,%ProjectDir%VirtualTestVirtualBox.script,"TxtAddLine#$c#$pDebugCmd#$p#$c#$qVBoxManage.exe sharedfolder add"
End
If,NotExistFile,%ProjectDir%VirtualTestVirtualBox.script,Message,"%ProjectDir%VirtualTestVirtualBox.script#$x Script not found, not modified",INFORMATION,5

#13 Aeolis

Aeolis

    Frequent Member

  • .script developer
  • 145 posts
  • Location:Rio de Janeiro
  • Interests:I am just trying to learn and help.
  •  
    Brazil

Posted 15 April 2012 - 10:00 PM

Hello folks,

Dear homes32, you are a genius! :1st:

I have tried out the AutoIt approach and it works like a charm. I have compiled the first version with tooltip. It's great. I need to learn about it, tell me more.... :loleverybody:

I have learned a bit of AutoIt from sbaeder sometime ago (when working on EaseUS ToDo Backup script) and I think is time to face my fears and push myself harder on it.

homes32 I would like to know if there is a possibility to make the AutoIt exe receive command line parameters, like:

-startfireBwall; so it installs WinpkFilter AND starts fireBwall;
-installwinpkfilter; so it only install Winpkfilter

homes32 I did a test to find possible vulnerabilities on the AutoIt script, so in my build I configured PENetwork.exe to keep on tray after it finishes (PENetwork.exe keeps running). Your AutoIt script wasn't supposed to do not run the defined command if PENetwork OR drvload.exe OR drvinst.exe OR penetcfg.exe were running?

In my test it run the defined command.


$Programs[0] = "PENetwork.exe"

$Programs[1] = "penetcfg.exe"

$Programs[2] = "drvload.exe"

$Programs[3] = "drvinst.exe"


Best regards,

Aeolis

P.S.: Again, homes32 your are a genius! You have a friend here on Brazil.

#14 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 16 April 2012 - 12:37 AM

glad it is working for you! :)

homes32 I would like to know if there is a possibility to make the AutoIt exe receive command line parameters, like:

-startfireBwall; so it installs WinpkFilter AND starts fireBwall;
-installwinpkfilter; so it only install Winpkfilter


yep! here is an example:

; Process Command line parms.

If Not $CmdLine[0] = 0 Then

Switch $CmdLine[1]

  Case "-startfireBwall"

   StartFirewall()

  Case "-installwinpkfilter"

   InstallWinpk()

EndSwitch

Else

; otherwise show help

MsgBox(64, $ProgramName & " v" & $ProgramVersion & " - By Aeolis", "Usage:" & @CRLF & @CRLF & "RunfireBwall.exe <Mode>" & @CRLF & @CRLF & "-startfireBwall - Start the firewall." & @CRLF & @CRLF & "-installwinpkfilter - Install the Winpkfilter driver which is necessary for operation.")

EndIf

or another way

If StringInStr($CmdLineRaw, "-installwinpkfilter") Then

; do something

End


homes32 I did a test to find possible vulnerabilities on the AutoIt script, so in my build I configured PENetwork.exe to keep on tray after it finishes (PENetwork.exe keeps running). Your AutoIt script wasn't supposed to do not run the defined command if PENetwork OR drvload.exe OR drvinst.exe OR penetcfg.exe were running?

In my test it run the defined command.


$Programs[0] = "PENetwork.exe"

$Programs[1] = "penetcfg.exe"

$Programs[2] = "drvload.exe"

$Programs[3] = "drvinst.exe"



the script will not continue if any of the programs in the array are running UNLESS the timeout period expires (default is 1 minute). you can set the timeout at the beginning of the PreStart function on the line

Local $ms = 60000 ; timeout value in milliseconds

this was built in in the case that somebody desired to have penetwork minimized to tray that this loader program would't endlessly loop and consume memory, never running the program, yet still allow plenty of time for networking operations to finish before running the program. feel free to adjust the timeout to a longer value if you need to or remove the feature entirely..just be aware that the program will "freeze" and reside in memory until penetwork.exe is terminated.


I defiantly recommend learning Autoit if you are up to it. Its really easy once you get into it, the community is top-notch and the documentation 2nd to none.
I learned a few years ago by just jumping in and writing VRL (VipreRescue Launcher...used in my VIPRERescue script) it took me a few months working a little each day to feel comfortable but was defiantly worth the time spent.

-homes32





Also tagged with one or more of these keywords: firebwall, winpkfilter, network, firewall

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users