setting variable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello,

how can I assign output of

pslist iexplorer | find "process iexplorer was not found" /C

to a variable in dos batch file?

(pslist is a program shows wanted programs in memory, returns lined strings)

Thanks..
 
Murat said:
hello,

how can I assign output of

pslist iexplorer | find "process iexplorer was not found" /C

to a variable in dos batch file?

(pslist is a program shows wanted programs in memory, returns lined strings)

Thanks..

Try this:

@echo off
for /F "tokens=*" %%* in ('pslist iexplorer ^| (cont. next line)
find "process iexplorer was not found" /C') do set x=%%*

Note this:
- It's probably "iexplore", not "iexplorer"
- This is not a DOS batch file - DOS is an operating system of its
own and it could not cope with this syntax. It's a Windows
batch file that you run in a Command Prompt.
 
tasklist /FI "imagename eq 1explorer.exe" |find "No tasks running with the specified criteria"&echo %errorlevel%

Errorlevel will be 0 if found and 1 if not.

If errorlevel 0 if not errorlevel 1 set flag=explorer running
If errorlevel 1 if not errorlevel 2 set flag=explorer not running

Note it is an assumption that a web browser is iexplore. Mine is explorer.

VBScript
ListOpenShellWindows.vbs

Set objShell = CreateObject("Shell.Application")
Set AllWindows = objShell.Windows
For Each window in AllWindows
msgbox window.locationname
Next

This displays all browser windows - there is no difference between IE and Explorer. So it will show C:\ and www.google.com.
 
And I'm searching for 1explorer so it's not found.

--
--------------------------------------------------------------------------------------------------
How to lose a war in Iraq
http://webdiary.com.au/cms/?q=node/1335#comment-48641
=================================================
"David Candy" <.> wrote in message tasklist /FI "imagename eq 1explorer.exe" |find "No tasks running with the specified criteria"&echo %errorlevel%

Errorlevel will be 0 if found and 1 if not.

If errorlevel 0 if not errorlevel 1 set flag=explorer running
If errorlevel 1 if not errorlevel 2 set flag=explorer not running

Note it is an assumption that a web browser is iexplore. Mine is explorer.

VBScript
ListOpenShellWindows.vbs

Set objShell = CreateObject("Shell.Application")
Set AllWindows = objShell.Windows
For Each window in AllWindows
msgbox window.locationname
Next

This displays all browser windows - there is no difference between IE and Explorer. So it will show C:\ and www.google.com.
 
Thanks all.

for /f %%a in (
'pslist program ^| find "process program was not found" /C'
) do set x=%%a


It really works great. Thanks Pegasus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top