Jump to content

Recommended Posts

Posted

I designed a DOS-based program to change the Wi-Fi hotspot of a laptop on Win7 that takes in SSID and Password as input from the user and set them as the hotspot's.

Then I saved it as a batch file. I want to make a GUI for a 'software' feel that takes those inputs in text-boxes and enters them in the Command Prompt after running the batch file.

Can I do that using VB? If so, please help me and tell how.. Thanks :)


Posted

Here is a basic HTA template that will return the user input, I used Microsoft Jscript as the language.

post-5386-0-99395000-1419528887_thumb.pn

 

<TITLE> « Wifi Changer » </TITLE> <HTA:APPLICATION ID="WifiChange"  APPLICATIONNAME="WifiC"  Border="Thin"  BORDERSTYLE ="Complex"  Caption="Yes"  Icon="%Windir%\explorer.exe"  INNERBORDER ="No"  MaximizeButton="No"   MinimizeButton="Yes"   Scroll="No"   SCROLLFLAT ="No"          SingleInstance="Yes"  SysMenu="Yes"             WindowState="Normal"/><STYLE Type='text/css'>  Body{Font-Size:9.25pt;Font-Weight:Bold;Color:Black;       Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;           BackGround-Color:#EFE9E3;Text-Align:Center;Vertical-Align:Top;       Margin-Top:11;Margin-Bottom:1;Margin-Left:4;Margin-Right:4;       Padding-Top:1;Padding-Bottom:1;Padding-Left:4;Padding-Right:4;       Border-Top:0px Transparent;Border-Bottom:0px Transparent;       Border-Left:0px Transparent;Border-Right:0px Transparent;  }  BUTTON{Cursor:Hand;Height:17pt;Width:35pt;         Font-Size:8.25pt;Font-Weight:Bold;Color:#001141;         Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;         Text-Align:Center;Vertical-Align:Middle;         Filter:progid:DXImageTransform.Microsoft.Gradient         (StartColorStr='AliceBlue',endColorStr='LightSlateGray');         Border-Top:1px Transparent;Border-Bottom:1px Transparent;         Border-Left:1px Transparent;Border-Right:1px Transparent;         Padding-Top:0;Padding-Bottom:2;Padding-Left:0;Padding-Right:0;         Margin-Top:1;Margin-Bottom:1Margin-Left:1;Margin-Right:1;  }  .Tx1{Font-Size:8.25pt;Font-Weight:Bold;  Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;}  Input{Font-Size:8.25pt;Font-Weight:Bold;Color:#004141;}  TD{Font-Size:8.25pt;Font-Weight:Bold;Color:#414141;}  FONT{Font-Size:8.25pt;Font-Weight:Bold;Color:#414141;}  FONT.FT1{Font-Size:8.25pt;Font-Weight:Bold;Color:Red;}</STYLE><SCRIPT LANGUAGE='JScript'>//-> Resize And Place In Approx center window.resizeTo(401,125) window.moveTo(screen.availWidth/2-(401/2),screen.availHeight/2-(125/2)) //-> Button Click Function  function MyButton1(){   if(Str.value.length==0){alert("Please fill in a wifi password");}   else{alert(Str.value);Str.value=""}} </SCRIPT> <BODY> <TABLE> <TD><FONT CLASS=''>Type in the wifi password  </FONT></TD>  <TD><INPUT Type='Text' ID='Str' Size=28 MAXLENGTH=28></TD>  <TD><BUTTON ID='Btn1' OnClick="MyButton1()">Process</BUTTON></TD> </TABLE><TABLE></BODY>
Posted

Why not just use this powershell script, I think it should perform exactly what you need, apart from the fact it has a fixed SSID, (can be added as a requested parameter if required).

 

Perhaps the only thing I can see which may be useful is a quit if the number of found adapters is 0.

 

Change Line 40 From:

Write-Host -Foregroundcolor Green "Found $(($WifiAdapters | Measure ).Count + 0) wifi adapters"

Change To:

$NumCnt = $(($WifiAdapters | Measure).Count + 0)If ($NumCnt -eq 0) {Exit}Write-Host -Foregroundcolor Green "Found $NumCnt wifi adapters"
Posted

Code I Tried As Test.ps1

#now that WiFi adapter is configured, let's add our hotspot$WifiPassSec = Read-host -Prompt "Enter password for your Wifi, must be at least 8 chars long, complex" -AsSecureString#enable hosted network$WifiPass = ConvertFrom-SecureToPlain $WifiPassSec$SetupHN = "netsh wlan set hostednetwork mode=allow ssid=Rivnet-Wifi key=`"$WifiPass`" keyUsage=persistent`nnetsh wlan start hostednetwork"Invoke-expression $SetupHN$SetupHN = $null$WifiPass = $null
If it an XP system and Powershell is not installed then the script would fail

When I tested this on Win 10 I had the wrong extension .ps it should of been .ps1. Now when I tried to run the script on Windows 7, using the power shell.

post-5386-0-05900500-1419639798_thumb.pn

What I got running it in the Power Shell ISE for Windows 10

post-5386-0-38148600-1419642994_thumb.pn

Posted

If it an XP system and Powershell is not installed then the script would fail

This is beginning to be tiresome!

I designed a DOS-based program to change the Wi-Fi hotspot of a laptop on Win7

 

Also, if you haven't configured your system to run powershell scripts, which incidentally does have the correct ps1 extension, then that is not within the remit of this question or solution.

Posted

Yzöwl that code will not work unless the OS has been modified to allow it to work, I am lost to as how that is better. If the code executed like this example that works perfect on Windows 7 without making any changes to the OS.

Get-Childitem C:\Windows\*.log

Directory: C:\Windows

Mode LastWriteTime Length Name

---- ------------- ------ ----

-a--- 12/12/2014 6:39 PM 45377 DirectX.log

-a--- 05/11/2014 10:11 AM 2790 DtcInstall.log

-a--- 05/11/2014 9:02 PM 18372 IE11_main.log

-a--- 06/11/2014 2:14 AM 4368 LDPINST.LOG

-a--- 20/11/2010 7:47 PM 4568 PFRO.log

-a--- 26/12/2014 10:01 PM 63281 setupact.log

-a--- 13/07/2009 9:51 PM 0 setuperr.log

-a--- 05/11/2014 10:11 AM 1355 TSSysprep.log

-a--- 27/12/2014 8:33 AM 1533849 WindowsUpdate.log

So what you are suggesting than is to use code that will only work when you have to modified every computer to allow it to work on.

Where as the HTA will always work on any XP, Vista, Win7, Win8, Win10 without modifications

Posted

Yzöwl that code will not work unless the OS has been modified to allow it to work, I am lost to as how that is better.

 

There-in lies your problem; if you must treat solutions in any language other that that in which you've posted as a competition then I'd suggest you simply refrain from future participation.

 

A HTA solution was suggested, therefore to ensure you were given the greatest chance of seeing it, I moved the original Topic to this Programming Forum.

 

Please read through my posts above and try to explain in a mature manner where I have so much as suggested that the powershell solution was better than a HTA, then when you've failed to do so perhaps an apology to myself and the readers of this group would be in order!

Posted

All I expected with the Powershell was it to work like the example that all, I did not

understand why it would not on Win 7 or Win 10 as is. When I read the link I understood

I had to make some changes, which I have choose not to make. I apologise for any my

misunderstanding

Posted (edited)

When I read the link I understood I had to make some changes, which I have choose not to make.

 

I don't get it :unsure:, the good MS guys that by default disabled in a standard install the execution of PowerShell scripts had in mind to protect your security, of course you cannot run PowerShell scripts if PowerShell scripts are disabled, it is like you want to connect to the internet but refuse to have an IP assigned by your local DHCP server and do not set it manually.  :unsure:

 

jaclaz

Edited by jaclaz
Posted

I guess it is kind of similar to having JavaScript disabled, which many people believe should also be the default setting.

 

Cheers and Regards

 

Note:  In general, I do approve of GSM's approach of providing solutions that can work on as many OS and machines as possible without changing any of the normal or default settings. While Powershell does seem to be a very "powerful" tool, I am a total neophyte in it's use.  But the more tools you have in your toolbox, and know how to use them, the better off you are.

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...