0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

プロキシの切り替えを簡単に行えるアプリをHTA(VBS)で作ってみた

Last updated at Posted at 2020-04-21

#経緯
先日身内の職場でSurfaceが配布された。しかし職場の人間(当人も含めて)プロキシについて理解しておらず、ポータブルPCなのにも関わらずだれも社外で使えないという意味の分からない状態になっているそうなので簡単にプロキシの切り替えを行えるアプリをVBSで制作した。
#仕様・外観

仕様

プロキシ名とポートを自分で設定出来る。自由度が高く、ブラウザ等から設定変更するよりスムーズに操作出来る(はず)。

外観

![sdf.PNG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/624501/178a167e-31ed-08cf-d728-9e487a7dd8ef.png)

#コード

change_proxy.hta
<html>
<head>
<meta charset = "UTF-8">
    <title>change_proxy</title>
</head>
<script language="vbscript">
' 画面サイズ変更
Sub Window_OnLoad
  Window.ResizeTo 540,330
End Sub
</script>

<body>
<form name="form1">

<p><br>
<input type="radio" name="rd" />プロキシ有効化<br></p>

<p>プロキシ名:ポート
<input type="text" name="text1" value="xxx.ne.jp:8080" />

</p>
<input type="radio" name="rd" checked />プロキシ無効化<br></p>
<input type="button" value="変更"
onClick="subGo()" />


<textarea name="kekka" cols="30" rows="4"></textarea>
</form>

  <script language="VBScript">
Sub subGo()

'値を取得
strKekka = "値を" & document.form1.text1.value & "に変更しました" & vbcr

'ボタンの値を取得
For i = 0 To document.form1.rd.length - 1
if document.form1.rd(i).checked then
loops = i + 1
end if
Next
if loops = 1 then
strRadio = "有効"
elseif loops = 2 then
strRadio = "無効"
end if

strKekka = strKekka & "プロキシは" & strRadio & vbcr



'値を返す
document.form1.kekka.value = strKekka


Dim objShell:Set objShell = CreateObject("WScript.Shell")
base = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\"

If strRadio = "有効" Then

objShell.RegWrite base + "ProxyEnable", 1, "REG_DWORD"
    objShell.RegWrite base + "ProxyOverride", "<local>"
    objShell.RegWrite base + "ProxyServer", document.form1.text1.value
Else

 objShell.RegWrite base + "ProxyEnable", 0, "REG_DWORD"
End If
End Sub
</script>
</body>
</html>

#参考
https://tanamon.hatenablog.jp/entry/20090417/1239935940

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?