Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Want a GUI for batch file

- - - - - GUI Visual Basic Visual Studio Batch file Input Execute DOS

  • Please log in to reply
14 replies to this topic

#1
el.uniqornio

el.uniqornio
  • Member
  • 1 posts
  • Joined 24-December 14
  • OS:Windows 7 x64
  • Country: Country Flag

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 :)




How to remove advertisement from MSFN

#2
Kelsenellenelvian

Kelsenellenelvian

    WPI Guru

  • Developer
  • 8,876 posts
  • Joined 18-September 03
  • OS:Windows 7 x64
  • Country: Country Flag
Hta would be the way to go there

#3
bphlpt

bphlpt

    MSFN Addict

  • Member
  • PipPipPipPipPipPipPip
  • 1,828 posts
  • Joined 12-May 07
  • OS:none specified
  • Country: Country Flag

And GunSmokingMan would probably be the best one to give you advise about HTA's.

 

Cheers and Regards


Posted Image


#4
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 10,022 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

Regarding HTAs, the relevant language used with them is VBScript. Alternatively, you can look into AutoIT.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
tpxmsfn1_zps393339c1.jpg

#5
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,859 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

Or if you want to remain strictly inside batch you can use WizApp, the Wizard Apprentice:

http://wizapp.sourceforge.net/

 

jaclaz


Edited by jaclaz, 25 December 2014 - 10:44 AM.


#6
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,435 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
Here is a basic HTA template that will return the user input, I used Microsoft Jscript as the language.
Attached File  WifiExample.png   153.98KB   0 downloads
 
<TITLE>&#160;&#171;&#160;Wifi Changer&#160;&#187;&#160;</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 &#160;</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>



GunSmokingMan



#7
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,579 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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"


#8
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,435 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
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.
Attached File  PsError.png   55.97KB   0 downloads

What I got running it in the Power Shell ISE for Windows 10
Attached File  Ps1Error.png   52.62KB   0 downloads


GunSmokingMan



#9
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,579 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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.



#10
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,859 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

@gunsmokingman

http://www.tech-reci...script_support/

 

 

jaclaz



#11
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,435 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
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


GunSmokingMan



#12
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,579 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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!



#13
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,435 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
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


GunSmokingMan



#14
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,859 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

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, Yesterday, 03:09 PM.


#15
bphlpt

bphlpt

    MSFN Addict

  • Member
  • PipPipPipPipPipPipPip
  • 1,828 posts
  • Joined 12-May 07
  • OS:none specified
  • Country: Country Flag

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.


Posted Image






Also tagged with one or more of these keywords: GUI, Visual Basic, Visual Studio, Batch file, Input, Execute, DOS

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users