Create a GUI for CLI

vaibhavyagnik

youtube.com/vaibhavyagnik
Adept
I am not a software engineer so please bear with me.
I need to use CLI on a regular and repeating basis for simple commands such as enabling network sharing. I will have to open command prompt, type in net share sharename=path /REMARK:"TEXT". I can create a .bat file for it and it works, but I want to create a program which lets user enter the sharename, the drive path and when the user presses ok, the command line will run in the background. How can I achieve this? Which program do I need to learn for this? Ideally it should be a .exe which will run without any dependencies.
 
Bash:
@echo off

setlocal EnableExtensions
setlocal EnableDelayedExpansion

echo "Enter path (without quotes even if it has spaces): "
set /p "SHAREPATH="
echo .
echo "Enter Sharename: "
set /p "SHARENAME="
echo .

net share sharename="%SHAREPATH%" /REMARK:"%SHARENAME%"
pause

This should do it. Why make an exe for such small task which can be done in batch script itself?
 
Won't it be better if this is done with Powershell which is where such scripting is happening these days ?

 
Bash:
@echo off

setlocal EnableExtensions
setlocal EnableDelayedExpansion

echo "Enter path (without quotes even if it has spaces): "
set /p "SHAREPATH="
echo .
echo "Enter Sharename: "
set /p "SHARENAME="
echo .

net share sharename="%SHAREPATH%" /REMARK:"%SHARENAME%"
pause

This should do it. Why make an exe for such small task which can be done in batch script itself?
Where can I learn all the possible ways I can use CLI to achieve what I want to? I just gave the network sharing as an example. But your code works. Thanks for this!
 
Where can I learn all the possible ways I can use CLI to achieve what I want to? I just gave the network sharing as an example. But your code works. Thanks for this!
Nothing specific. As and when the requirement pops up I google stuff like "take user input in cmd". You only need to learn how to google stuff properly and of course practice coding.
 
I had done a school project like this. Basically, I created an Internet download manager by using cURL CLI. It was pretty easy. I used C# and visual studio
 
Were you able to develop the UI? If not, one alternative to the already suggested approach will be using AutoIT software which can give you a basic user form with just a few lines of code. It also integrates very well with Windows platform.
 
I have written a ton of python scripts that i need to use, but not very often. So I tend to forget how to use them, like what are the parameters etc.

For a while I used .bat files with a shortcut in a folder on my Windows Desktop, but once I started using a Mac laptop along with my Windows PC then I faced issues doing this cross-platform.

Recently I have started making cross-platform UIs using "Tkinter" to put a UI on my scripts. It takes a few hours to put the UI on an existing script.

If you also want to use UI on mobile or touchscreens then can use something like "Kivy".
 
Back
Top