@echo off : NETSHARE.BAT created 20050904 by wmc, Iterate Pte Ltd : Internet Explorer security settings can prevent graceful launch : of browser-based active content from removable media such as : CD-ROMs and flash memory drives. This script attempts to open : the entrypage using a network share name, rather than using the : local file system. Using a network share name also works with : non-IE browsers. The script detects the operating system and if : not Windows XP or later, loads the entrypage via file system. : The script uses the 'net share' command to make the current : folder accessible as 'sharepath'. This allows the content to be : accessed via UNC path (eg- "\\%computername%\sharepath\index.htm"). : Since this script is launched from the 'autorun.inf' file, it : will in most cases be run from a removable drive (unless during : testing). There is no real danger in allowing removable media to : run as a shared network resource. Although the sharepath setting : will persist after the session is completed, the name is hidden, : only one user at a time may access the share, and for many types : of distributed removables, the media is read-only. : The reason for running removables as a shared network resource : is to bypass security warnings about untrusted 'Active' content, : which one may encounter using WinXP Service Pack 2 (or later) : with default security settings. However in certain environments : the user's rights may not be sufficient to permit assignment of : a UNC path using the 'net share' command. In such situations, : the script simply launches the entry page and leaves security : settings as an exercise for the user. : To modify IE browser security settings manually, the user may : do the following: In IE's menu select 'Tools, Internet Options'. : Click on the 'Advanced' tab and scroll down to the 'Security' : section. Tick the box that reads 'Allow active content from CDs : to run on My Computer'. One may of course revert this tick box : to its original setting on completion of the presentation. : Rev: 20070721 by wmc, substantial changes to share the current : working directory, rather than try to detect the CD-ROM drive. : Also paramaterised, so entryfile can be read from command line. : Also ensured that sharepath is hidden (using '$'), and that : browser detection supports Vista and later OS ('tasklist' is : a command that was not available prior to XP). :ns_get_params set ns_sharepath=removable$ set ns_entryfile=%1 if "%ns_entryfile%" == "" set ns_entryfile=index_cd.htm :ns_browser_detection ver | find /i "Version 5." > nul if not errorlevel 1 goto ns_check_computername ver | find /i "Version 6." > nul if not errorlevel 1 goto ns_check_computername tasklist > nul if not errorlevel 1 goto ns_check_computername echo Apparently the OS is not Windows XP or later. goto ns_manual_launch :ns_check_computername if "%computername%" == "" goto ns_err1 :ns_remove_existing_sharepath net share %ns_sharepath% | find /i "%ns_sharepath%" > nul if errorlevel 1 goto ns_assign_sharepath net share %ns_sharepath% /d > nul :ns_assign_sharepath net share %ns_sharepath%=%cd% /users:1 /r:"Can be removed." > nul if errorlevel 1 goto ns_err2 echo Successfully configured shared path for network access. :ns_uncpath_launch set unc_share=\\%computername%\%ns_sharepath%\%ns_entryfile% start %unc_share% if errorlevel 1 goto ns_err3 goto ns_exit :ns_err1 echo Error - unable to determine 'computername' environment variable. goto ns_manual_launch :ns_err2 echo Error - unable to share the current folder as a network drive. echo This action requires Win2000 or later OS. Or perhaps your login echo account does not have authority to share network resources. goto ns_manual_launch :ns_err3 echo Error - unable to launch presentation using UNC path: echo '%unc_share%'. goto ns_manual_launch :ns_manual_launch echo. echo The file '%ns_entryfile%' will be opened to display the echo presentation, and you will need to configure your own browser echo security settings to allow active content. If you face further echo problems, contact your system administrator for assistance. echo. start %ns_entryfile% goto ns_exit :ns_exit set ns_sharepath= set ns_entryfile= set unc_share= echo.