Jump to content

ProxHTTPSProxy and HTTPSProxy in Windows XP for future use


AstroSkipper

Recommended Posts


2 minutes ago, TuMaGoNx said:

After reading more about proxhttpsproxy, I confused as how is the whole thing different from privoxy, configured with ssl enabled? If tls 1.3 needed just add wanted cipher and update the mbedtls/openssl. Someone post https://msfn.org/board/topic/183726-privoxy-as-ssl-filter/ but no one chime in. :unsure:

ProxHTTPSProxy is easy and great. Read my first post in this thread and my short tutorial from here: 

What I need now are further ideas, tips, suggestions or at its best, solutions for my question! :yes:

Link to comment
Share on other sites

So, I've made a bit more progress. Microsoft's "start" command has a bug. It must not be called "start /wait /b" but "start /b /wait". That's great! I love Microsoft! :realmad: Microsoft's documentation of this command is crap. Unfortunately, closing the ProxHTTPSProxy's status window in the corner right above leads to closing the complete process tree. This means that the rest of my batch file can't be executed anymore. :( However, if I use my task manager "ProcessHacker" and specifically close the file "ProxHTTPSProxy.bat", my batch works perfectly. :) Very strange! Any ideas or suggestions?

Cheers, AstroSkipper matrix.gif

PS: The next try will be a compiled version of my batch file. Don't know if this change anything! :dubbio:

Edited by AstroSkipper
Update of content
Link to comment
Share on other sites

You need a loop checking that the process is running, issue may be that continuous loops in batch use lots of CPU time, so usually a timeout is inserted in the loop, since a timeout/sleep command is not available in XP, you will need a third party tool or use one of the poor man's alternatives, such as Ping.

AutoIt does not use as much CPU as batch AFAICR, still a timeout/sleep would probably be needed.

There are workarounds, like the excellent:

https://www.bill2-software.com/processmanager/

but it seems to me like a bit too complex if a quick AutoIt would do it. (this is a sort of taskmanager that - among many other features - allows to monitor a process and do something whenever the process is started or closed)

BTW if start /wait works, you can use/spawn a child process, check:

https://ss64.com/nt/start.html

maybe you don't want to use the /b option?

Start /wait has a whole number of issues, you need a lot of experiments to find the "right" command line.

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

4 hours ago, jaclaz said:

You need a loop checking that the process is running, issue may be that continuous loops in batch use lots of CPU time, so usually a timeout is inserted in the loop, since a timeout/sleep command is not available in XP, you will need a third party tool or use one of the poor man's alternatives, such as Ping.

AutoIt does not use as much CPU as batch AFAICR, still a timeout/sleep would probably be needed.

There are workarounds, like the excellent:

https://www.bill2-software.com/processmanager/

but it seems to me like a bit too complex if a quick AutoIt would do it. (this is a sort of taskmanager that - among many other features - allows to monitor a process and do something whenever the process is started or closed)

BTW if start /wait works, you can use/spawn a child process, check:

https://ss64.com/nt/start.html

maybe you don't want to use the /b option?

Start /wait has a whole number of issues, you need a lot of experiments to find the "right" command line.

jaclaz

@jaclaz Thanks for your reply and  your point of view! AutoIt is certainly worth a try. At the moment I am struggling with pure batch programming. And what can I say? I programmed a loop checking wether the proxy is running or not in a simple batch.  When the proxy is closed manually, my batch goes on and deactivates the proxy's settings as it should be. :cheerleader: Actually, I should be very happy, but the processor load on the one hand and the intense background activity on the other still bother me. nonono.gif Have to think about that in general, and of course, about possibilities of optimization! idee.gif And I still need alternatives! Any ideas or suggestions are welcome!

Cheers, AstroSkipper thinking.gif

Edited by AstroSkipper
Update of content
Link to comment
Share on other sites

6 hours ago, AstroSkipper said:

I programmed a loop checking wether the proxy is running or not in a simple batch.  When the proxy is closed manually, my batch goes on and deactivates the proxy's settings as it should be. :cheerleader: Actually, I should be very happy, but the processor load on the one hand and the intense background activity on the other still bother me. nonono.gif Have to think about that in general, and of course, about possibilities of optimization! idee.gif

Hi to all! :hello: I optimized my batch file to reduce CPU load. After a lot of tests and adjusting the code, I compiled my bat file to an exe. The processor load is now ok i.e. normal. The background activity is less than before, but frankly, it still bothers me. It would  be great if some more ideas or suggestions were offered to solve the problem described in my previous posts. Perhaps, there are also other solutions than a loop. Anyway, I was able to create an exe file with the functionality of @heinoganda's ProxHTTPSProxy_PSwitch.exe. :cheerleader: It was not as easy as it might seem. Honestly, I am not such an elegant programmer, and the file ProxHTTPSProxy_PSwitch.exe I like more, but my file definitely works, and that's most important. I love simple and functional solutions. At the moment, though, I don't know wether I'll end up using it in my PopMenu. It's a decision about whether you like something or not. grattermenton.gif

Cheers, AstroSkipper matrix.gif

Edited by AstroSkipper
Update of content
Link to comment
Share on other sites

Greetings.

On 7/20/2022 at 1:45 AM, Dave-H said:

So what does the ProxHTTPSProxy.exe file actually do in ProxyMII?
Does it just run the ProxHTTPSProxy.bat batch file?

No. They do the same and don't depend on each other.

ProxHTTPSProxy.exe is a dummy exe from PIP ("Lib\site-packages\pip\_vendor\distlib\t32.exe") + something name "shebang" ("#!./python.exe") + zip-archive of __main__.py with just one string - "import ProxHTTPSProxy".

16 hours ago, AstroSkipper said:

What kind of ways do exist to start an executable in a batch file, and, after closing it manually, to perform the next tasks in this batch?

I find something. It must call "on_exit" function then window closed. I'll try to integrate it.

import win32api
import time

def on_exit(signal_type):
   print('caught signal:', str(signal_type))
   time.sleep(1)
   for i in range(1,5):
     print (6-i)
     time.sleep(1)

win32api.SetConsoleCtrlHandler(on_exit, True)
time.sleep(30)
17 hours ago, TuMaGoNx said:

Privoxy? I'd something like it... But why did I abandon it and not use it? I don't remember... Do You know how to test it and get it to work?

https://mega.nz/file/Hk1mQL6L#hag3q96mhhvlHqPd7gxwNQY2pjcCqq-Ce3aRJSYLi34 - package (minimal set of files to launch)

https://mega.nz/file/fwMDCJoJ#3JPVB33oAiBQ5fTLqVhuk1XfkfXXWndlDVA6iv8Yh50 - full copy of dev folder.

Best regards.

Link to comment
Share on other sites

4 hours ago, cmalex said:
22 hours ago, AstroSkipper said:

What kind of ways do exist to start an executable in a batch file, and, after closing it manually, to perform the next tasks in this batch?

I find something. It must call "on_exit" function then window closed. I'll try to integrate it.

import win32api
import time

def on_exit(signal_type):
   print('caught signal:', str(signal_type))
   time.sleep(1)
   for i in range(1,5):
     print (6-i)
     time.sleep(1)

win32api.SetConsoleCtrlHandler(on_exit, True)
time.sleep(30)

Hi @cmalex. Thanks for your reply! What functionality exactly do you want to integrate? You know I do not have any skills in the programming language Python. I am just a batch programmer If at all. As far as I can see, the code you posted is a loop in python. You try to catch the event of ProxHTTPSProxy's exit. Is that right? Anyway, it would be great if you integrated the functionality of activating the proxy's LAN settings on its start and deactivating on its exit. upp.gif I already did that by creating a batch, compiled to an exe file, providing such functionality. But the background activity still bothers me. A more elegant solution is welcome at any time, of course! :yes: 

Cheers, AstroSkipper matrix.gif

Edited by AstroSkipper
Update of content
Link to comment
Share on other sites

Hi @cmalex! Here is the code of my batch to show you my implementation of the functionality described above:

@ECHO OFF
TITLE Start ProxHTTPSProxy
cmdow "Start ProxHTTPSProxy" /HID
START /MIN "Activate Proxy" ActivateProxy.bat
CD..
START "ProxHTTPSProxyMII v1.5" ProxHTTPSProxy.exe
CD PopMenu
:LOOP
tasklist | find /i "python37" >NUL 2>&1
IF ERRORLEVEL 1 (
  GOTO CONTINUE
) ELSE (
  sleep 10
  GOTO LOOP
)

:CONTINUE
START /MIN "Deactivate Proxy" DeactivateProxy.bat
EXIT

As you can see, the activation and deactivation are done by the batch files ActivateProxy.bat and DeactivateProxy.bat. After hiding the program's window, my file activates the LAN settings, starts the proxy, performs a loop checking whether python37 is running or not, and deactivates the LAN settings on the proxy's exit. The file sleep.exe is an alternative to timeout.exe, which is not compatible with Windows XP, to perform a delay. I decided to use the program tasklist.exe inside the loop because it has an ERRRORLEVEL output I needed. If all this is done by using a higher programming language such as Python, it will presumably lead to less processor load and less background activity. If you want to take a look into my files, let me know! BTW, any improvements or optimizations of my code are welcome, of course! :yes: 

Cheers, AstroSkipper matrix.gif

PS: Although I had my doubts, such functionality can actually be realised with pure batch programming. q.e.d.

Edited by AstroSkipper
Update of content
Link to comment
Share on other sites

Hi to all! Just a short update! Due to a tip from @cmalex about the correct use of the command START /WAIT I was able to solve my problem completely. Microsoft's documentation is flawed and misleading. :realmad: I was very close to the solution, but I couldn't find the correct syntax of the command START /WAIT. This command is buggy, and its documentation, too. I wasted a lot of time in trying all combinations of this START /WAIT command. Thanks for that bug, Microsoft! pcwut.gif  Anyway,  I modified the code of my batch file, and it works perfectly. ssupercool2.gif No further need of a loop! No unnecessary background activity! Exact what I wanted to achieve! :cheerleader: Therefore, no further solutions are necessary, the problem is solved. o-k.gif  And once again, many thanks to @cmalex! :thumbup You are an excellent programmer as far as I can tell! :yes:

Cheers, AstroSkipper matrix.gif

Edited by AstroSkipper
Update of content
Link to comment
Share on other sites

@AstroSkipper It's not buggy you need to add Window Title. Example of correct order. You find like 10.000 lines of code in XP2ESD, you can take many code examples there :)

start /wait "SDI" "%~dp0SDIO.exe" 

Using CMDOW is bad, it's flagged as virus from like 2006. Use native VBS instead to run application silently

Invisible.vbs (accepts parameters too)

 

	' Run hidden cmd with arguments
Dim Args()
ReDim Args(WScript.Arguments.Count - 1)
	For i = 0 To WScript.Arguments.Count - 1
    Args(i) = """" & WScript.Arguments(i) & """"
Next
	CreateObject("WScript.Shell").Run Join(Args), 0, True
	

And then use it this way

%WinDir%\System32\wscript.exe //nologo "invisible.vbs" "%~dp0apps\Cleanup.exe"
Edited by George King
Link to comment
Share on other sites

4 hours ago, George King said:

@AstroSkipper It's not buggy you need to add Window Title. Example of correct order. You find like 10.000 lines of code in XP2ESD, you can take many code examples there :)

start /wait "SDI" "%~dp0SDIO.exe" 

Hi @George King! Thanks for your reply! The command start /wait is definitely buggy, confirmed several times. I tried it in my first version of my batch, and it doesn't work as described by Microsoft. Therefore, your statement is not correct. Due to a bug in the command start /wait it works in some cases, and in others it doesn't. It depends on the program you want to launch with this command. Due to a tip from @cmalex  about the correct use I was able to get rid of the bug. But once again, in some cases it may work. In my case,  unfortunately, it fails. In the case of cmdow, I have had no problems so far. I love it. amoureuxcoeur.gif It has a lot of interesting parameters. Here is a link: https://ritchielawrence.github.io/cmdow/#usage  The tool is virus-free and certainly cannot be blamed for false alarms. But, I'll test your Invisible.vbs as an alternative, too. In any cases, thanks for your efforts! I do appreciate that! :yes:

Cheers, AstroSkipper matrix.gif

Edited by AstroSkipper
Update of content
Link to comment
Share on other sites

16 minutes ago, George King said:

@AstroSkipper Can you explain me more bug you are talking about?

Of course! In the case of @cmalex's PROXYMII the command start /wait doesn't work as it should do. It leads to an interruption of the batch with output ^C and a question to abort or to continue if the proxy's status window was closed manually. In a test batch I created it worked with the program notepad. You see in some cases it works, in others it doesn't! @cmalex already knew that there is a bug in this command. And I stated it a few posts before, too. :yes:

Edited by AstroSkipper
Update of content
Link to comment
Share on other sites

@AstroSkipper I saw that in past. It was not bug in start /wait, but it was caused by used workaround in called app by using some kind of "SendKeys" commands. 

Of course, when you need to wait until is finished, another crazy workaround is possible.

start /wait "XX" cmd /c start mypapp.exe

And it can be also launched using invisible.vbs. Yes, it's crazy, but doable, until problematic code in called app is fixed :)

 

And yes, there could be like another 1000 different reasons why you see it as "bug" :)

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...