Show /Hide on Network

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MrChuCong
Posts: 4
Joined: 15 Feb 2011 10:32

Show /Hide on Network

#1 Post by MrChuCong » 03 Mar 2012 01:51

I have the script as follows:
@echo off
goto main
:main
cls
echo 1 Show on Network
echo 2 Hide on Network
echo 3 Exit
:choice
set /P C=[1,2,3]?
if "%C%"=="1" goto showit
if "%C%"=="2" goto hideit
if "%C%"=="3" goto exitit
:showit
net config server /hidden:no
:hideit
net config server /hidden:yes
:exitit
exit

So it can work well? :D

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Show /Hide on Network

#2 Post by foxidrive » 03 Mar 2012 05:08

I haven't tested this but there are some fixes below.

Code: Select all

@echo off
goto :main
:main
cls
echo 1 Show on Network
echo 2 Hide on Network
echo 3 Exit
:choice
set "C="
set /P C=[1,2,3]?
if not defined c goto :choice
if "%C%"=="1" goto showit
if "%C%"=="2" goto hideit
if "%C%"=="3" goto exitit
goto :main
:showit
net config server /hidden:no
goto :EOF
:hideit
net config server /hidden:yes
goto :EOF
:exitit
exit
goto :EOF

Post Reply