You are here

A PortableApp for the Traveller and his USB stick?

18 posts / 0 new
Last post
englishman
Offline
Last seen: 11 years 3 months ago
Joined: 2010-02-03 11:10
A PortableApp for the Traveller and his USB stick?

Just wondered whether anyone uses (or knows of) a utility, running off a USB stick that could:

1. Confirm that you have a live internet connection
2. Determines the IP address and then the Internet Service Provider of the connection is (helps if you need to use the ISP's SMTP mail server)
3. What Firewall and Anti-virus the host machine recognises as being installed.
4. What the Operating System, RAM and disk space available is.
5. Whether you are in an Admin user or not (helps to know if you can load your Truecrypt volume etc.)

I know there are various utilities that do some of these, but I haven't come across anything that is kind of tailored for the traveller and his USB stick.

At the moment I do all this through a DOS batch script containing mixture of DOS commands/utilities and a few built-in windows programs that I kick off once I have inserted the USB stick. e.g. (NSLOOKUP, WMIC, PING, http-ping wscui.cpl etc) but it's not pretty.

If there isn't something already out there, then I wondered whether a little utility developed for the PortableApps traveller could be useful?

What do other travellers do?

Devildevilscle
Offline
Last seen: 12 years 4 months ago
Joined: 2010-11-08 13:18
Are u saying. .

Are you saying that if there's none of what you're searching, you'll gonna develop something like that? Maybe you can search for some tools that might do one of the jobs you need at nirsoft.net & portablefreeware.com

-:O =

englishman
Offline
Last seen: 11 years 3 months ago
Joined: 2010-02-03 11:10
No... not saying I can develop anything, but...

what I am saying is that there doesn't seem to be a single portable application that accomplishes these tasks, which I would assume would be some of the most important information needed for someone who used their USB on the road as I do.

There are a shed load of portable programs that can give you a too much information about the operating system etc. There are others that can tell you what your network IP address is etc. You can get firewall and AV info from running wscui.cpl in a DOS window.

But as far as I know there isn't a single app that can do all of this and present it in s single small window. It would be great to see a PortableApp developed and maintained here that could do just that.

At the moment I run a DOS batch script that accomplishes this in a very primitive way. It runs this script to query information and display it in the DOS window or via a number of windows control panel windows such as wscui.cpl.

This information enables me to know whether I can load Truecrypt (if I have admin rights). It tells know whether I have enough memory to run something like VLC Portable. It helps me know if there is any point in loading Portable Firefox (if I don't actually have an internet connection). It helps me know what address I need to set for outgoing SMTP mail when I load Portable Thunderbird. It helps me to know some basic securiity about the PC via wscui.cpl.

So, to answer your question... no, I don't have the knowledge to create a portableapp, but I do have some knowledge about how to get this info in DOS and what windows commands can be used. It's just ain't very pretty at the moment, and wondered what others do that might be better than this. I would love to see a portable utility developed that could get an agreed basic set of PC, network and security info in a single application.

solanus
solanus's picture
Offline
Last seen: 10 years 1 month ago
Joined: 2006-01-21 19:12
SIW

SIW has all the information you are asking for, but there's so much more info in the app, it would take a bit of time to go through it all; you can customize a report to some extent, though, that might help.

As a traveller, I generally deal with these issues like this:
1. Try my browser. If it doesn't work, I usually talk to the owner of the computer I'm using, since it's either a friend, an institution, or a netcafe.
2. This has always been too much trouble for me, so I use a webmail account when travelling, or I use mail2web.com.
3. SIW, although usually this info is easily available from the System Tray
4. SIW or run MSINFO32
5. SIW

I suppose it wouldn't be too difficult to write a WMI script to just output this info automatically.

When I'm travelling, I tend to assume that as a I am either a guest or I am in a public space, that I should expect a certain level of restriction, such as no admin rights or access to the host's OS or drivespace.

I made this half-pony, half-monkey monster to please you.

englishman
Offline
Last seen: 11 years 3 months ago
Joined: 2010-02-03 11:10
Yes, SIW is very good, but....

... you can't load it without Admin rights which kind of makes it a lot less useful (unless you know of a way around that restriction). The info I need can be obtained without Admin rights. SIW does seem to have good commandline support to produce a customised report on certain info only... Great program, shame it needs admin rights.

I guess I'd be looking for something similar that could provide simpler, customised info on network, pc and security info without the need for admin rights. I don't need to know the finer detail (it's information overload), just need to have some basic info about the system, network and security in one small screen of info. Is there anything out there that does that (portable and no admin rights)? Thanks.

ottosykora
Offline
Last seen: 17 hours 29 min ago
Joined: 2007-10-11 17:48
I travel often too

but found so far no needs for something like that.

Details about ISP:
hmmm, what for? Just see if internet is working, enter some website to the browser and you know.
To find out the isp, nice, but today this is of no big advantage. This permanent swapping of smtp is over, most isp will not authenticate the smtp with their ip range any more, they have to use port587 which means authentication by user/password and so you can use such smtp from where ever you are.

To check for security settings, well depends on the os, something like xp or many linux distros will not give you such info unless you have admin pw of some kind.

While forced to use other peoples computer some time, I have always two identical sticks with me, hardware encryption, not truecrypt, so if the one is badly hit by some malware, some backup is then around.

Otto Sykora
Basel, Switzerland

englishman
Offline
Last seen: 11 years 3 months ago
Joined: 2010-02-03 11:10
Agree that finding out SMTP mailserver has changed...

... and is much less of an issue than it used to be.

XP Professional SP3 in non-admin user runs wscui.cpl just fine. I've not found a PC that it fails to run on.

Getting a connection can be a problem if you are using your own laptop and USB away from your normal wi-fi. I'd rather not wait until PFF loads from my USB stick to find out if there is an connection problem.

I agree that this all info can be found by various methods. It just takes longer. I'd rather use PING or other utility to check connectivity than wait for Portable FF to load.

mjashby
Offline
Last seen: 9 months 2 weeks ago
Developer
Joined: 2008-09-19 13:35
System Information

I've been following this discussion with some interest. There are any number of software tools which do what you want, but I really don't understand your specific problem. As far as I can tell, the vast majority of information you say you want/need can be readily found using either basic observation (System Tray) or the Windows Control Panel of the machine you are using, so why this desperate need for extra software? Yes, SIW and similar Tools are extremely useful for probing the innermost workings of PCs but, in general, they are overkill in most situations.

MJA

englishman
Offline
Last seen: 11 years 3 months ago
Joined: 2010-02-03 11:10
Yes, agree that most of the info can be found...

... but I am looking to automate things as much as possible and save time. Agree SIW is overkill for this.

At the moment I have this DOS login script that does pretty much all of this for me. I guess all I really want to know as soon as I login or plugin my USB to a new PC is:

Do I have an internet connection?
Is this a limited account?
How much RAM is there (and maybe processor speed)?
What kind of firewall/anti-virus is running?

I suppose could run this script in a hidden DOS window and output the results in a simple Alert box with the text inside. I just thought there might be something already out there that did this far more neatly without an ugly DOS window showing up.

Ed_P
Offline
Last seen: 6 years 1 month ago
Joined: 2007-02-19 09:09
Maybe?

For item 1 maybe one of these would help:

netstat -r
ipconfig /all

For OS, RAM and processor a sysdm.cpl Window gives all that.

I don't see any need for knowing what kind of FW/AV is running unless you're looking to bypass them.

Ed

solanus
solanus's picture
Offline
Last seen: 10 years 1 month ago
Joined: 2006-01-21 19:12
WMI scripting

It's been a while since I've worked with WMI scripts, but in the past I've been able to run them on systems with merely User access. I don't know if that's changed as of W7.
With a modicum of research on The Scripting Guys page, it shouldn't be too hard to create a very simple script that only outputs the information that the English is looking for.
I'm not volunteering, though, since I don't have the time or need for this, but for someone that does, it should be straightforward.

I made this half-pony, half-monkey monster to please you.

Bahamut
Bahamut's picture
Offline
Last seen: 13 years 1 week ago
Joined: 2006-04-07 08:44
PowerShell

On Windows 7, PowerShell is the way to go, but there are some caveats. It's only included by default on W7 (and Server 2008 R2 IIRC), and the default policy is to not run unsigned scripts (even locally). I can't remember if the policy can be changed with only user privileges (for just the current user obviously). If it can, it can be done with one line of code.

Vintage!

englishman
Offline
Last seen: 11 years 3 months ago
Joined: 2010-02-03 11:10
Thanks

I don't know anything about WMI scripting, but I will have a look.

Ed_P
Offline
Last seen: 6 years 1 month ago
Joined: 2007-02-19 09:09
Computer Profiler

Would one of Karen's apps help? I'm thinking the Computer Profiler one. And if it's missing something the source is available so you could modify it to better meet your needs.

http://www.karenware.com/powertools/powertools.asp

Ed

englishman
Offline
Last seen: 11 years 3 months ago
Joined: 2010-02-03 11:10
Thanks

I will take a look, but at first glance it seems a bit overkill for what I need.

Joe at KarenWare.com
Offline
Last seen: 7 years 3 months ago
Joined: 2017-08-23 14:23
Cool idea...

I don't know how portable any of the apps are, yet, but Karen's Portable Power Tools has a nice ring to it.

solanus
solanus's picture
Offline
Last seen: 10 years 1 month ago
Joined: 2006-01-21 19:12
Goldilocks

The chances that someone has created an app that exactly fits your need without being too much or too little - well, let's say probably not too likely.
If you are using a batch file, why not just post the batch file in this thread? Maybe someone can take it and make it a little nicer and more efficient.

P.S. There are a few other sites you might look to:
portablefreeware.com
winpenpack.com

but be careful, there are also a fair number of questionable sites that claim portable software.

I made this half-pony, half-monkey monster to please you.

englishman
Offline
Last seen: 11 years 3 months ago
Joined: 2010-02-03 11:10
Ok... here's an extract

OK, that's fine. I think I pretty much have the functionality, but would love to have this appearing as a simple windows pop-up rather than an ugly DOS window.

Rather than post the whole script which does other things (such as check if local network storage is attached, automated backups etc). I have pasted below an extract of the script with all the relevant parts. It runs fine, but does rely on a few executables being present on the USB drive:
WINMSG (displays a message with options for actions) from http://www.westmesatech.com/wast.html
wget (DOS download utility) from http://gnuwin32.sourceforge.net/packages/wget.htm
http-ping (PING for http) from http://www.coretechnologies.com/products/http-ping/ - I found that ordinary PING was not accurate in correctly determining whether I had browser http access.

The script may also have some superflous variables used in the main script. These can be ignored.

If you decide to run it (at your own risk) you will need to download the 3 utilities and place them in the STARTLIB directory. The full script runs for me on XP x32, Vista x32 and Win 7 x64. I have checked that this cut and paste job runs for me on Win 7, and as long as I haven't messed up it should be OK on Vista and XP.

@ECHO OFF
@COLOR f8
SETLOCAL ENABLEDELAYEDEXPANSION

set CURRDRV=%cd:~0,2%\
SET STARTLIB=%CURRDRV%start

IF NOT EXIST "%CURRDRV%temp\%COMPUTERNAME%\" md "%CURRDRV%temp\%COMPUTERNAME%\"
IF NOT EXIST "%STARTLIB%\" md "%STARTLIB%\"

CALL :FINDADMINUSER

CALL :GETPCDETAILS

CALL :SETFILEPATHS

CALL :CHECK_FIREWALL

CALL :CHECK_AV

CALL :CHECK_INTERNET_ACCESS

CALL :GETIPDETAILS

echo.&echo.
pause
exit

:GETPCDETAILS
TITLE Checking Computer Memory
SET MEMFILE=%CURRDRV%temp\%COMPUTERNAME%\memory.txt
IF EXIST "%MEMFILE%" SET /p RAM= %CURRDRV%temp\%COMPUTERNAME%\ram.txt
for /f "tokens=4* delims=: " %%a in (%CURRDRV%temp\%COMPUTERNAME%\ram.txt) do set TotalMemWithComma=%%a
set RAM=%TotalMemWithComma:,=%
echo %RAM% > %MEMFILE%
:DETAIL2
TITLE Checking Computer Operating System
SET OSFILE=%CURRDRV%temp\%COMPUTERNAME%\os.txt
IF EXIST "%OSFILE%" SET /p OSNAME= %CURRDRV%temp\%COMPUTERNAME%\osname.txt
for /f "tokens=1,2 delims=:" %%a in (%CURRDRV%temp\%COMPUTERNAME%\osname.txt) do set OSN=%%b
for /f "tokens=* delims= " %%a in ("%OSN%") do set OSNAME=%%a
echo %OSNAME% > %OSFILE%
:DETAIL3
SET OSTYPE=%CURRDRV%temp\%COMPUTERNAME%\ostype.txt
IF EXIST "%OSTYPE%" SET /p OSNAMETYPE= %CURRDRV%temp\%COMPUTERNAME%\osnametype.txt
for /f "tokens=1,2 delims=:" %%a in (%CURRDRV%temp\%COMPUTERNAME%\osnametype.txt) do set OST=%%b
for /f "tokens=* delims= " %%a in ("%OST%") do set OSNAMETYPE=%%a
echo %OSNAMETYPE% > %OSTYPE%
:DETAIL4
IF NOT EXIST %CURRDRV%temp\%COMPUTERNAME%\systeminfo.txt systeminfo.exe > %CURRDRV%temp\%COMPUTERNAME%\systeminfo.txt
echo "%OSNAME%" |findstr /i /l "XP" >nul
IF %ERRORLEVEL% EQU 0 IF "%ADMIN%" == "N" GOTO DETAIL5
TITLE Checking Computer Disk Space
for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='%SYSTEMDRIVE%'" get FreeSpace /format:value`) do set FreeSpace=%%x
for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='%SYSTEMDRIVE%'" get Size /format:value`) do set Size=%%x
call :StrLength LENGTH %Size%
SET /A POS = %LENGTH% - 9
CALL :Substring SizeGB,%Size%,0,%POS%
call :StrLength LENGTH %Freespace%
SET /A POS = %LENGTH% - 9
CALL :Substring FreeGB,%Freespace%,0,%POS%
set /a Percentage=100 * FreeGB / SizeGB
rem set OSNAME=%OSNAME: =%&SET OSTYPE=%OSTYPE: =%
:DETAIL5
echo.&echo Opertating System is %OSNAME%%OSNAMETYPE%
echo Memory=%RAM%MB RAM
IF /I %RAM% LEQ 1024 GOTO:EOF
echo "%OSNAME%" |findstr /i /l "XP" >nul
IF %ERRORLEVEL% EQU 0 IF "%ADMIN%" == "N" GOTO:EOF 
echo Drive %SYSTEMDRIVE% size is %SizeGB%GB, Freespace is %FreeGB%GB (%Percentage%%%)
GOTO:EOF

:SETFILEPATHS
rem must come after GETPCDETAILS
TITLE Setting Path Names
echo "%OSNAME%" |findstr /i /l "XP" >nul
IF %ERRORLEVEL% EQU 0 SET ALLWINSTARTUP=%ALLUSERSPROFILE%\Start Menu\Programs\Startup&SET WINSTARTUP=%USERPROFILE%\Start Menu\Programs\Startup&SET RECENTITEMS=%USERPROFILE%\Recent&SET SENDTO=%USERPROFILE%\SendTo&SET OS=%OS% Windows XP&SET SECURITYCENTER=NAMESPACE:\\root\SecurityCenter&GOTO WINCHECK2
echo "%OSNAME%" |findstr /i /l "Vista" >nul
IF %ERRORLEVEL% EQU 0 SET ALLWINSTARTUP=%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup&SET WINSTARTUP=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup&SET RECENTITEMS=%APPDATA%\Microsoft\Windows\Recent&SET SENDTO=%APPDATA%\Microsoft\Windows\SendTo&SET OS=%OS% Windows Vista&SET SECURITYCENTER=NAMESPACE:\\root\SecurityCenter2&GOTO WINCHECK2
echo "%OSNAME%" |findstr /i /l "Windows 7" >nul
IF %ERRORLEVEL% EQU 0 SET ALLWINSTARTUP=%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup&SET WINSTARTUP=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup&SET RECENTITEMS=%APPDATA%\Microsoft\Windows\Recent&SET SENDTO=%APPDATA%\Microsoft\Windows\SendTo&SET OS=%OS% Windows 7&SET SECURITYCENTER=NAMESPACE:\\root\SecurityCenter2&GOTO WINCHECK2
:WINCHECK2
echo "%OSNAMETYPE%" |findstr /i /l "64" >nul
IF %ERRORLEVEL% EQU 0 (
SET MEMEO="%ProgramFiles(x86)%\WD\WD Anywhere Backup\MemeoLauncher2.exe"
SET USBDEVIEW=%STARTLIB%\USBDeview\x64\
SET SETACL=%STARTLIB%\setACL\x64\
) ELSE (
SET MEMEO="%ProgramFiles%\WD\WD Anywhere Backup\MemeoLauncher2.exe"
SET USBDEVIEW=%STARTLIB%\USBDeview\x32\
SET SETACL=%STARTLIB%\setACL\x32\
)
GOTO:EOF

:FINDADMINUSER
TITLE Checking Access Credentials
NET USER "%USERNAME%" >%CURRDRV%temp\%COMPUTERNAME%\netusers.txt 2>NUL
find "*Administrators"  NUL
IF %ERRORLEVEL% EQU 0 (
echo.&echo Current user %USERNAME% HAS Admin Rights&SET ADMIN=Y
) ELSE (
echo.&echo Current user %USERNAME% HAS NO Admin Rights&SET ADMIN=N
)
GOTO:EOF

:CHECK_FIREWALL
TITLE Checking if Windows Firewall enabled
set FirewallStatus=
:CF1
netsh firewall show state | findstr /i /l "Operational Mode" > %CURRDRV%temp\%COMPUTERNAME%\firewall.txt
for /f "tokens=1,2 delims==" %%a in (%CURRDRV%temp\%COMPUTERNAME%\firewall.txt) do (
set LABEL=%%a
for /l %%a in (1,1,20) do IF "!LABEL:~-1!"==" " set LABEL=!LABEL:~0,-1!
IF "!LABEL!" == "Operational mode" SET FirewallStatus=%%b&GOTO CF2
)
:CF2
echo "%FirewallStatus%" |findstr /i /l "Disable" >nul
IF %ERRORLEVEL% NEQ 0 GOTO CF3
echo.&echo WARNING: WINDOWS FIREWALL IS TURNED OFF!
GOTO:EOF
:CF3
echo "%FirewallStatus%" |findstr /i /l "Enable" >nul
IF %ERRORLEVEL% NEQ 0 echo.&echo Windows Firewall Status neither enabled nor disabled&GOTO:EOF
echo.&echo Windows Firewall is ENABLED
GOTO:EOF

:CHECK_AV
TITLE Checking What Anti-virus is installed
:CAV1
SET AVSTATUS=
WMIC /? >NUL 2>&1 ||        GOTO CAV1A
wmic /%SECURITYCENTER% PATH AntiVirusProduct GET * /value 2> NUL  %CURRDRV%temp\%COMPUTERNAME%\avinfo.txt
IF %ERRORLEVEL% EQU 0 GOTO CAV1B
:CAV1A
echo.&echo Unable to detect Anti-virus software, please check
IF "%BACKUP%" == "N" START /b /MIN wscui.cpl
GOTO:EOF
:CAV1B
for /f "tokens=1,2 delims==" %%a in (%CURRDRV%temp\%COMPUTERNAME%\avinfo.txt) do (
set LABEL=%%a
rem for /l %%a in (1,1,20) do IF "!LABEL:~-1!"==" " set LABEL=!LABEL:~0,-1!
IF "!LABEL!" == "displayName" SET AVSTATUS=%%b&GOTO CAV2
)
:CAV2
IF NOT "%AVSTATUS%" == "" GOTO CAV3
IF "%BACKUP%" == "N" START /b /MIN wscui.cpl
%STARTLIB%\WINMSG.EXE -t "No Anti-virus software" -m "NO ANTI-VIRUS DETECTED!\nContinue?" -c AbortRetryIgnore,Exclamation,SystemModal
IF %ERRORLEVEL% EQU 3 EXIT
IF %ERRORLEVEL% EQU 4 echo.&GOTO CAV1
echo.&echo NO ANTI-VIRUS DETECTED!&SET MESSAGE=NO ANTI-VIRUS DETECTED!\n\n
GOTO:EOF
:CAV3
echo.&echo %AVSTATUS% is INSTALLED
GOTO:EOF

:CHECK_INTERNET_ACCESS
TITLE Checking Internet Connection
:CIA1
%STARTLIB%\http-ping http://www.google.com -n 2 -w 10 -v >NUL
IF %ERRORLEVEL% EQU 100 SET INTERNET=Y&GOTO CIA2
rem rundll32.exe van.dll,RunVAN
start /b /min control.exe /name Microsoft.NetworkandSharingCenter
start /b /min control.exe netconnections
%STARTLIB%\WINMSG.EXE -t "No Internet" -m "No Internet Access Detected!\nContinue?" -c AbortRetryIgnore,Exclamation,SystemModal
IF %ERRORLEVEL% EQU 3 EXIT
IF %ERRORLEVEL% EQU 4 GOTO CIA1
SET MESSAGE=Internet access currently unavailable!
echo.&echo %MESSAGE%
SET INTERNET=N
:CIA2
rem "%STARTLIB%\cmdow.exe" "Network Connections" /cls 2>NUL
GOTO:EOF

:GETIPDETAILS
TITLE Checking ISP provider, IP address and SMTP server names
IF "%INTERNET%" == "N" GOTO:EOF
"%STARTLIB%\wget\bin\wget.exe" --output-document="%CURRDRV%temp\%COMPUTERNAME%\ip.txt" --output-file="%CURRDRV%temp\%COMPUTERNAME%\iplog.txt"  "http://www.whatismyip.com/automation/n09230945.asp" 2>NUL
IF %ERRORLEVEL% NEQ 0 GOTO:EOF
IF NOT EXIST "%CURRDRV%temp\%COMPUTERNAME%\ip.txt" GOTO:EOF
SET /p IP=NUL >%CURRDRV%temp\%COMPUTERNAME%\nslookup.txt
IF %ERRORLEVEL% NEQ 0 GOTO:EOF
for /f "tokens=1,2" %%a in (%CURRDRV%temp\%COMPUTERNAME%\nslookup.txt) do (
set LABEL=%%a
IF "!LABEL!" == "Name:" SET LOOKUP=%%b
)
for /f "tokens=1-5 delims=." %%a in ("%LOOKUP%") do (
SET PINGER=%%b.%%c.%%d.%%e
ping -a !PINGER! >NUL
IF !ERRORLEVEL! EQU 0 GOTO PINGEND
SET PINGER=%%c.%%d.%%e
ping -a !PINGER! >NUL
IF !ERRORLEVEL! EQU 0 GOTO PINGEND
SET PINGER=%%d.%%e
ping -a !PINGER! >NUL
IF !ERRORLEVEL! EQU 0 GOTO PINGEND
SET PINGER=%%d.%%e
ping -a !PINGER! >NUL
IF !ERRORLEVEL! EQU 0 GOTO PINGEND
SET PINGER=%%e
ping -a !PINGER! >NUL
IF !ERRORLEVEL! EQU 0 GOTO PINGEND
:PINGEND
SET DOMNAME=!PINGER!
)
ECHO "%ISP%" |findstr /i "%DOMNAME%" >nul
IF %ERRORLEVEL% EQU 0 SET SMTPMAILSERVER=smtp.%DOMNAME%&GOTO DISPLAYDETS
PING smtp.%DOMNAME% >NUL
IF ERRORLEVEL EQU 0 SET SMTPMAILSERVER=smtp.%DOMNAME%&GOTO DISPLAYDETS
PING mail.%DOMNAME% >NUL
IF ERRORLEVEL EQU 0 SET SMTPMAILSERVER=mail.%DOMNAME%
:DISPLAYDETS
echo.&echo IP: %ip%  ISP: %DOMNAME% SMTP MAIL SERVER: %SMTPMAILSERVER%
echo Hostname: %LOOKUP%   
GOTO:EOF

:Substring
::Substring(retVal,string,startIndex,length)
:: extracts the substring from string starting at startIndex for the specified length 
 SET string=%2%
 SET startIndex=%3%
 SET length=%4%
 
 if "%4" == "0" goto :noLength
 CALL SET _substring=%%string:~%startIndex%,%length%%%
 goto :substringResult
 :noLength
 CALL SET _substring=%%string:~%startIndex%%%
 :substringResult
 set "%~1=%_substring%"
GOTO :EOF
 
:StrLength
::StrLength(retVal,string)
::returns the length of the string specified in %2 and stores it in %1
set #=%2%
set length=0
:stringLengthLoop
if defined # (set #=%#:~1%&set /A length += 1&goto stringLengthLoop)
::echo the string is %length% characters long!
set "%~1=%length%"
GOTO :EOF

[Put in <pre> block - mod Chris]

Log in or register to post comments