This is a batch file I wrote designed for a user in a contracting environment to be able to easily switch between the corporate PAC and their customer’s PAC. If the current PAC is set to the customer’s (or is blank), it will switch it to the corporate PAC; otherwise it will set the PAC to the customer’s. Only the two variables at the top need be edited.
For reference, this is the setting in question:
rem -- Set proxy values in following two lines --
set KEY_NAME="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
FOR /F "usebackq skip=1 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
@echo Current proxy is %PROXY_VALUE%
IF "%PROXY_VALUE%"=="%OUR_COMPANY%" (
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d "%THEIR_COMPANY%" /f
echo Proxy switched to %THEIR_COMPANY%
) else (
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d "%OUR_COMPANY%" /f
echo Proxy switched to %OUR_COMPANY%
This code snippet will allow you to check if you are running with elevated permissions or not. Original credit goes to http://www.robvanderwoude.com/clevertricks.php. However, the script there is not Windows 7 compatible as the “at” command is deprecated. Here I use netstat with the “-b” parameter, which requires administrator privileges.
netstat -a -n -b > nul
if %ERRORLEVEL% equ 0 (
echo You are Administrator.
) else (
echo You are NOT Administrator.
This batch file will share all of the folders in a given directory. I chose batch over PowerShell as it does not have the ability to natively share folders (in Server 2008), though you can do it via WMI. I would prefer using shell commands. It simply uses the folder name as the share name and grants everyone full permissions (share permissions, not NTFS permissions). Simply pass the desired directory containing the directories you wish to share as the first parameter. Otherwise, it will use the current directory by default. You must not end the parameter with “\”, or net share will refuse to accept the syntax; thus if you want to share everything in D:\, pass the parameter as D: .
if not defined folder set "folder=%cd%"
for /d %%a in ("%folder%\*") do (
for %%* in ("%%a\.") do net share "%%~n*"="%%a" /grant:everyone,FULL /unlimited