@echo off
title Network
echo Network

call WinVars.bat

echo Creating a loopback interface...
%SystemRoot%\System32\devcon.exe install %windir%\inf\netloop.inf *msloop

echo Waiting for the loopback interface to be up...

sleep 75

net user "%GUESTUSER%" /active:yes
ntrights +r SeNetworkLogonRight -u "%GUESTUSER%" 
ntrights -r SeDenyNetworkLogonRight -u "%GUESTUSER%" 

md "%SYSTEMDRIVE%\Share" 

sleep 2

takeown /a /r /f "%SYSTEMDRIVE%\Share" /d Y

Xcacls "%SYSTEMDRIVE%\Share" /p "%EVERYONEGROUP%":F "ANONYMOUS LOGON":F /t /c /y

sleep 2

if %SETUPOSCONFIG%==Seven net share "Share"="%SYSTEMDRIVE%\Share" /grant:"%EVERYONEGROUP%",FULL /grant:"ANONYMOUS LOGON",FULL /unlimited /remark:"Share folder"
if %SETUPOSCONFIG%==2008 net share "Share"="%SYSTEMDRIVE%\Share" /grant:"%EVERYONEGROUP%",FULL /grant:"ANONYMOUS LOGON",FULL /unlimited /remark:"Share folder"
if %SETUPOSCONFIG%==Vista net share "Share"="%SYSTEMDRIVE%\Share" /grant:"%EVERYONEGROUP%",FULL /grant:"ANONYMOUS LOGON",FULL /unlimited /remark:"Share folder"
if %SETUPOSCONFIG%==2003 net share "Share"="%SYSTEMDRIVE%\Share" /grant:"%EVERYONEGROUP%",FULL /grant:"ANONYMOUS LOGON",FULL /unlimited /remark:"Share folder"
if %SETUPOSCONFIG%==XP rmtshare \\127.0.0.1\Share="%SYSTEMDRIVE%\Share" /grant "%EVERYONEGROUP%":F  /grant "ANONYMOUS LOGON":F /unlimited /remark:"Share folder"
if %SETUPOSCONFIG%==2000 rmtshare \\127.0.0.1\Share="%SYSTEMDRIVE%\Share" /grant "%EVERYONEGROUP%":F  /grant "ANONYMOUS LOGON":F /unlimited /remark:"Share folder"


echo Removing the loopback interface...
sleep 3
%SystemRoot%\System32\devcon.exe remove *msloop

echo.
exit
