Simulate "ok" via command line

Asked

Viewed 861 times

1

I have a Windows prompt command that disables proxy settings:

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\" /v ProxyEnable /t REG_DWORD /d 0 /f

My system browsers are configured to use my system settings. The command works, but not in real time - the effects only happen when I go to the Windows menu of the proxy setting and click on "ok" there.

Ok?

How do I simulate this "ok" via prompt?

  • Nothing! I just needed time to test.

  • I didn’t even notice that I had given the down, but it wasn’t even in your answer was it? It had been in my own question.

  • 1

    Thank you very much, it’s very good your question..

  • You have to use several ways, just need to test the keys first, see how it interacts c the "interface", then use them in the code to configure what is necessary..

3 answers

8


• Testado nas seguintes versões do Windows® •: XP Pro 32 bits, 7 Pro 64 bits, 8.0 Pro 64 bits & 10 Pro 64 bits


:: I believe you can make use of the sendKey (in VBS), to make some keystrokes shortcut, as Tabs, Arrows, Etc... needed to arrive at the button OK and then send the ENTER, that will function as a Click!!

@echo off & setlocal enabledelayedexpansion

>"%temp%\_temp_file_4vbs_.vbs"^
    (
     echo/ Set WshShell = WScript.CreateObject^("WScript.Shell"^)
     echo/ Set objShell = WScript.CreateObject^("WScript.Shell"^)
     echo/ Wscript.Sleep 1500
     echo/ objShell.AppActivate "inetcpl.cpl"
     echo/ Wscript.Sleep 100
     echo/ WshShell.SendKeys "({UP})"
     echo/ Wscript.Sleep 1500
     echo/ WshShell.SendKeys "(+{TAB})"
     echo/ Wscript.Sleep 1500
     echo/ WshShell.SendKeys "(+{UP})"
     echo/ Wscript.Sleep 1500
     echo/ WshShell.SendKeys "({TAB})"
     echo/ Wscript.Sleep 1500
     echo/ WshShell.SendKeys "({TAB})"
     echo/ Wscript.Sleep 2000
     echo/ WshShell.SendKeys "({ENTER})"
    ) & set "_temp_vbs=%temp%\_temp_file_4vbs_.vbs" 

start "" /w "%Windir%\System32\inetcpl.cpl" 
start "" /w "%Windir%\System32\wScript.exe" //nologo "!_temp_vbs!"
del /q /f "!_temp_vbs!" & goto :eof

Obs.: To open the tab directly "connections" via cmd/bat, use the command below:

start "" /w rundll32.exe Shell32.dll,Control_RunDLL Inetcpl.cpl,,4 inserir a descrição da imagem aqui


Update: Setando home page e VPN


inserir a descrição da imagem aqui

@echo off & setlocal enabledelayedexpansion

>"%temp%\_temp_file_4vbs_.vbs"^
    (
     echo/ Set WshShell = WScript.CreateObject^("WScript.Shell"^)
     echo/ Set objShell = WScript.CreateObject^("WScript.Shell"^)
     echo/ StrHomePage  = "http://www.google.com/ncr"
     echo/ StringProxy  = "http://proxy.stackoverflow.com.br:3128"
     echo/ Wscript.Sleep 100
     echo/ objShell.AppActivate "inetcpl.cpl"
     echo/ for h=1 To Len^(StrHomePage^)
     echo/     x = Mid^(StrHomePage,h,1^)
     echo/     WshShell.SendKeys x
     echo/     Wscript.Sleep 150
     echo/ Next
     echo/     Wscript.Sleep 1000
     echo/ WshShell.SendKeys "({UP})"
     echo/ Wscript.Sleep 100
     echo/ WshShell.SendKeys "(+{TAB})"
     echo/ Wscript.Sleep 100
     echo/ WshShell.SendKeys "(+{UP})"
     echo/ for i=1 to 3
     echo/    WshShell.SendKeys "({TAB})"
     echo/    Wscript.Sleep 1000
     echo/ Next
     echo/ WshShell.SendKeys "({TAB})"
     echo/ Wscript.Sleep 1000
     echo/ WshShell.SendKeys "({ENTER})"
     echo/ Wscript.Sleep 1000
     echo/ WshShell.SendKeys "({BACKSPACE})"
     echo/ for j=1 To Len^(StringProxy^)
     echo/     x = Mid^(StringProxy,j,1^)
     echo/     WshShell.SendKeys x
     echo/     Wscript.Sleep 150
     echo/ Next 
     echo/    WshShell.SendKeys "({TAB})"
     echo/    WshShell.SendKeys "({END})"
     echo/    WshShell.SendKeys " "
     echo/    WshShell.SendKeys "2"
     echo/    WshShell.SendKeys "({TAB})"
     echo/    Wscript.Sleep 1000
     echo/ for k=1 to 3
     echo/    WshShell.SendKeys "({TAB})"
     echo/    Wscript.Sleep 1000
     echo/ Next
     echo/ WshShell.SendKeys "({ENTER})"
     echo/ for l=1 to 5
     echo/    WshShell.SendKeys "({TAB})"
     echo/    Wscript.Sleep 1000
     echo/ Next
     echo/ WshShell.SendKeys "({ENTER})"
     echo/
    ) & set "_temp_vbs=%temp%\_temp_file_4vbs_.vbs"

start "" /w "%Windir%\System32\inetcpl.cpl"
start "" /w "%Windir%\System32\wScript.exe" //nologo "!_temp_vbs!"  
del /q /f "!_temp_vbs!" && goto :eof

4

That’s not possible, and for good reason.

Imagine if it were possible to simulate mouse clicks by the user. Just imagine, for a moment.

Now imagine a malware that does this.

Now imagine that so you could:

  • Disable Firewall and Windows Defender;
  • Disable anti-virus;
  • Send items to the trash;
  • Empty the trash can;
  • Dislocate the user;
  • Turn off the machine;
  • With a little imagination, you could have a service that observes what processes the user opens. Wait for him to open a browser, log into an internet banking site with known layout... Simulate a fake screen, send the browser window there, and transfer the user’s money to a temporary account of you.

For these reasons, much that deals with machine security requires at least a user confirmation. Sometimes they ask for an involvement that goes beyond that.

In time: you are some nineteen years behind in the concept of that your virus. The Cult of the Dead Cow invented the Back Orifice to do things like what you want. Fortunately and for the good of humanity, this is no longer so easy to do since some versions of Windows ago.

  • 1

    Oops, it’s not a virus and I’m not trying to simulate mouse movement. It’s a script I’m doing to apply proof in computer labs here at school.

  • 3

    @Johnschmitz however good the intention, the program you propose to do has the characteristics of malware. If you manage to bypass Windows security to make it work (it is possible, for example, by emulating a USB device), possibly all anti-viruses on the market will say that your program is one of the most dangerous malware.

  • 2

    So it was my approach to the problem, what kind of solution can be implemented in this case? Because of how the network architecture here works, turning off the network card would not help, since it needs to be connected to the local network, so my solution was to disable the proxy of computers...

  • 1

    @Johnschmitz I understand your problem. Infra is not my area, so unfortunately I can’t think of anything other than setting up each machine manually. You may be able to save time by setting up a single virtual machine, and upload the same image of that machine to every physical machine you use... Then your students can take the VM test.

  • 1

    @Johnschmitz I was once a student and employee of a college. My degree was in Computer Science and I was a lab monitor and member of the IT team. I understand the delicate balance that is to protect the school/college network while freeing up access to what is essential for teachers and students. Unfortunately this is something that is not simple :( I hope you find a good solution to your problem.

  • 1

    -1 - "this is not possible" is simply false, since it is possible.

  • 1

    On the contrary, what "would not be possible" would be to disable any way of doing this - even if microsoft broke the official Apis, it would still be possible to circumvent this by several ways. Don’t confuse "I believe you shouldn’t create a solution that depends on it" with "it’s not possible".

  • @Renan Bye, good night, forgive me for commenting! Understand that my participation in the platform only operates in answering questions,.

Show 3 more comments

1

You can try creating a proxy.reg file:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000001
"ProxyServer"="http://<proxyEndereco>:<porta>"

If you want to run in a bat enough:

regedit /s "c:\caminho\proxy.reg"

Or make a bat to change directly on the record:

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d <proxyEndereco>:<porta> /f

You are only changing Proxyenable

Reset Network Settings:

NETSH INT IP RESET all
netsh winsock reset all
ipconfig /release 
Ipconfig /flushdns
  • So, I just want to change the state of this record even, for convenience’s sake, since browsers use the system settings and they are disabled in the browser will also be. The problem is in that GUI, the changes only happen when I press that "OK" button I wanted to simulate that ok by command line.

  • Have you tried to close and reopened your browser? It may be that it starts with proxy x and does not update, so when you go in the settings it just updates.

  • I have tested with them both open and closed, these changes (change from either 0 or 1 the value of the record) only work by pressing that same ok...

  • I edited my answer, try the last commands.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.