Jump to content
Geej

Everything Search Engine - v1.3.3.658b

Recommended Posts

Both when trying to uninstall the previous version integrated via WinToolkit, and also when trying to install the latest version on a live system via the inf file, this error appears. Is it happening to others or only for me? You can confirm / infirm by trying to unistall the app - this error appears before uninstalling begins.

Share this post


Link to post
Share on other sites

Are you getting the error on x64?

(X86 tested ok.)

Please check whether tskill.exe is present in system32 folder on x64 OS. Have u also try on x86 as well? 

Cheers

Share this post


Link to post
Share on other sites

Yes!

There is a problem with the new update!

Something changed inside the program "Everything.exe 1.3.0.632b"

 

I found a workaround and works fine for me on Windows 7 x86.

You can try to use this Everything.inf file instead.

 

Note: I used inside SFX file and works fine !

Everything.rar

Edited by myselfidem

Share this post


Link to post
Share on other sites

@myselfidem Much obliged if you could share the generated .sfx file via mediafire or smth.

 

I'm only a semi-advanced user when it comes to silent installer making, so as the right-click install option is out of the question for what you've attached, and I'm lazy enough to generate a config file for the way I know to generate .7z installers... Thanks. :)

Share this post


Link to post
Share on other sites

This one installs just fine, however gives the same tskill error when trying to uninstall. :( Oh, and it's also in french (just kidding). :D

 

Thank you for trying. Maybe some .reg entries were changed in the new version regarding uninstalling process of Everything? Or maybe smth is wrong only with my pc... :(

Share this post


Link to post
Share on other sites

Strange, because I have no errors installing or uninstalling EverythingSearch.exe (SFX file) !

 

*Edit: You uninstall from Add/Remove programs ?

 

As Geej asked you, look at C:\Windows\system32 to find tskill.exe

post-23163-0-10855800-1359327096_thumb.p

Edited by myselfidem

Share this post


Link to post
Share on other sites

I was kidding with the language. :) Thanks however for the screen, tskill.exe is really where it's supposed to be, I don't think this is the issue. I'll try again on a fresh install. Thanks again. :)

Edited by RicaNeaga

Share this post


Link to post
Share on other sites

Maybe that can solve your issue! I changed inside Everything.inf:

[CloseProgram]TASKKILL /F /IM Everything.exe /T

 

You can download and try "EverythingSearch-1.3.rar" with the link given previously!

 

HTH

Share this post


Link to post
Share on other sites

Yes!!!!! This is it!!!! Both installing and unistalling without issue!!!! Great!!! Thank you! :)

 

 

@Geej Please update your addon with myselfidem changes regarding taskkill, both for installing and also uninstalling Everything. His latest .inf inside the 1.3 .7z installer solves both problems I've had with yours. :)

Share this post


Link to post
Share on other sites

Ok, will upload when got time.

I think I will make it a conditional execution so that error message will not even appear at all.

[CloseProgram]

cmd /c if exist %11%\taskkill.exe TASKKILL /F /IM everything.exe /T

Thanks to myselfidem for suggesting this alternative approach.

(I have this thought too but no time to response, beside why no tskill.exe is a mystery for RicaNeaga)

RicaNeaga thanks for your feedback. When you are on x64, can you also test it out?

Share this post


Link to post
Share on other sites

Tested myselfidem's installer in vm 7 x64, and everything is ok also on the x64 front, both regardin install and also uninstall. I'm going to test yours as an addon once you'll update it, both in x86 and x64 environments. Thanks. :)
 
 
LE: Maybe you'll find usefull the .reg entries left by the (new - 1.3.0.632b) original installer, for both x64 and x86. Below...
 
For x64:

Windows Registry Editor Version 5.00



[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Everything]
"DisplayName"="Everything 1.3.0.632"
"UninstallString"="C:\\Program Files (x86)\\Everything\\Uninstall.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run]
"Everything"="\"C:\\Program Files (x86)\\Everything\\Everything.exe\" -startup"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Search Everything...\command]
""="\"C:\\Program Files (x86)\\Everything\\Everything.exe\" -path \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.efu]
""="Everything.FileList"
"Content Type"="text/plain"
"PerceivedType"="text"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Everything.FileList]
""="Everything File List"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Everything.FileList\DefaultIcon]
""="C:\\Program Files (x86)\\Everything\\Everything.exe, 1"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Everything.FileList\shell\open\command]
""="\"C:\\Program Files (x86)\\Everything\\Everything.exe\" \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Everything.FileList\shell\edit\command]
""="\"C:\\Program Files (x86)\\Everything\\Everything.exe\" -edit \"%1\""

 

For x86:

Windows Registry Editor Version 5.00



[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Everything]
"DisplayName"="Everything 1.3.0.632"
"UninstallString"="C:\\Program Files\\Everything\\Uninstall.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Everything"="\"C:\\Program Files\\Everything\\Everything.exe\" -startup"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Search Everything...\command]
""="\"C:\\Program Files\\Everything\\Everything.exe\" -path \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.efu]
""="Everything.FileList"
"Content Type"="text/plain"
"PerceivedType"="text"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Everything.FileList]
""="Everything File List"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Everything.FileList\DefaultIcon]
""="C:\\Program Files\\Everything\\Everything.exe, 1"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Everything.FileList\shell\open\command]
""="\"C:\\Program Files\\Everything\\Everything.exe\" \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Everything.FileList\shell\edit\command]
""="\"C:\\Program Files\\Everything\\Everything.exe\" -edit \"%1\""

 

There is a new insteresting association with .efu files - don't see why not associate it with this rare extension. Or am I wrong?

Edited by RicaNeaga

Share this post


Link to post
Share on other sites

I have made a sfx version with uninstall support based on the work of Geej and myselfidem (thanks to them) with my own modifications:

 

 

The changes are:

 

- tasks are created with xml file, so you have to manually edit them if you want to have the task description in your language.

- Everything is localized in French (swapped everything.ini with mine)

- edited the inf file to remove the live install section,  context menu entries, and localize the uninstall strings in French

- removed the reg file as it is not really needed: the sfx is always executed at first launch or after (live install), so  rundll32 advpack.dll,LaunchINFSection %windir%\inf\Everything.inf,Install don't have to be executed on the next boot. I have added the line directly in the sfx config file and that works.

 

Tested on Win7 X86 and X64 with VirtualBox. Install and uninstall works fine on my tests.

 

If someone want to test it/adapt it to his needs, here is the file:

 

http://www.mediafire.com/?fcmy41p8n8yb9pf

 

Feedbacks are welcome !

Edited by mooms

Share this post


Link to post
Share on other sites

Base on RicaNeaga post #65 info for uninstall entry for x64, I have modified the Add/Remove registry key path to

HKLM,SOFTWARE\WOW6432NODE\Microsoft\Windows\CurrentVersion\Uninstall\Everything


(to align with the original installer path)

Everything save the search result as .csv/.efu/.txt (via File->Export).
If you save as .efu, double-click on it immediately open the result in Everything. (hence the file association)
If save in .txt/.csv, then it opens in notepad/Excel (On my system, .csv is open in Excel)

Thanks to all for x64 info/test/suggestion/ideas. :)

 

Also awaiting RicaNeaga feedback on x64 as an integrated .WA addon (no hurry)
 

Share this post


Link to post
Share on other sites

First of all, I can confirm it works great installed on a live win 7 x86 system via .inf - right click - install. Both install / uninstall don't generate any more issues. I'll edit this post after testing it as an addon. :)

Share this post


Link to post
Share on other sites

Base on RicaNeaga post #65 info for uninstall entry for x64, I have modified the Add/Remove registry key path to

(to align with the original installer path)

Everything save the search result as .csv/.efu/.txt (via File->Export).

If you save as .efu, double-click on it immediately open the result in Everything. (hence the file association)

If save in .txt/.csv, then it opens in notepad/Excel (On my system, .csv is open in Excel)

Thanks to all for x64 info/test/suggestion/ideas. :)

 

Also awaiting RicaNeaga feedback on x64 as an integrated .WA addon (no hurry)

 

 

 

Great work Geej !

 

Tested live install on x86 and x64:

 

 

 

- Install and uninstall works perfectly on both arch (shortcuts and tasks are created, everything is correctly deleted on uninstall)

 

However, the task don't work on x64, neither on startup or with the (UAC) shortcut.

 

It's because the task try to launch Everything with this path:  "%ProgramFiles%\Everything\Everything.exe"

 

it should be this one: "%ProgramFiles(x86)%\Everything\Everything.exe"

 

 

I think XML approach is more simple and easier, it works all the time when batch approach is way more complicated and don't works all the time.

If localization is a concern you can simply change the task description to "Everything" and it will be language neutral afaik.

 

i have updated my sfx in my previous post based on your new inf. Very good work.

Edited by mooms

Share this post


Link to post
Share on other sites

@Geej

 

When I install using right-clic and select install works fine...But using silent install (SFX file) a black screen appears and the computer "freeze". I must restart the computer with the button. After restart a message box says:

 

 

cmd.exe does not start correctly error (0xc0000142)

 

However, I thing the trouble is with Everything.inf

 

I made some changes inside Everything.inf to avoid this error and works fine for me.

You can test it if you want:

http://www.mediafire.com/?hp0b5c4nm2sdk

I made also some changes inside Everything_Schedule.bat

 

HTH

Edited by myselfidem

Share this post


Link to post
Share on other sites

Thanks, will study your changes.

Meanwhile, updated in Post #1

Tested ok on VM x86. Includes Everything64.xml (but not tested)

Note: Shortcut Everything (UAC) now launch w/o cmd box shown at all.

I have upload switchless using 7xsfx. (please test it on x86/x64 :). Works okay on x86)

(I'm uploading for 1 time switchless format only - will host for 14 days)

Please see whether you get cmd error or not.

<dl link removed>

EverythingSearchEngine_1.3.0.632bSi.exe

Size: 543.28 Kb (556,323 bytes)

MD5: E8B177253B2C831E4C92143AAA3F3958

Thanks everyone for the feedback. Really appreciate it. :)

Edited by Geej

Share this post


Link to post
Share on other sites

Thanks Geej! ;)

Tested your SFX file on my computer Windows 7 x86 and works really fine...

No more pop up alert window about cmd.exe

 

Regards

 

*Edit: I was the culprit inserting all files inside Everything folder, and there were always cmd.exe error!!!

Edited by myselfidem

Share this post


Link to post
Share on other sites

Tested successfully on my computer with Windows 7 64bit and works really fine.
Using the batch file given on my link (Mediafire) and without xml file!
 
Everything_Schedule.bat

::*******************************************:::: Everything_Schedule.bat                   :::: Set variables TaskName, Task and go ahead :::: http://myunster.com]http://myunster.com   ::::*******************************************::@ECHO offREM Delete variables, may be cachedSET "TaskName="SET "Task="REM Set variablesSET TaskName=EverythingREM Following task will be executed on Logon:PROCESSOR:: Detect OS bit-ness on running system.  Assumes 64-bit unless 64-bit components do not exist.SET "ARCH=64"IF NOT EXIST "%SystemRoot%\SysWOW64\cmd.exe" (                IF NOT DEFINED PROCESSOR_ARCHITEW6432 SET "ARCH=32"        )        ::Begin install        IF "%ARCH%"=="64" (        SET Task=\"C:\Program Files (x86)\Everything\Everything.exe\" -startup        ) ELSE (        SET Task=\"C:\Program Files\Everything\Everything.exe\" -startup        )REM Determine if windows xpVER | find "XP" > NULIF %ERRORLEVEL% == 0 GOTO ver_xpREM Determine if windows Vista/Win7systeminfo | find "OS Name" > %TEMP%\osname.txtFOR /F "usebackq delims=: tokens=2" %%i IN (%TEMP%\osname.txt) DO SET Version=%%iDEL /F %TEMP%\osname.txtECHO %Version% | find "Windows 7" > NULIF %ERRORLEVEL% == 0 GOTO ver_7ECHO %Version% | find "Windows Vista" > NULIF %ERRORLEVEL% == 0 GOTO ver_vista::ver_xp:Run Windows XP specific commands here.REM Delete variable, may be cachedSET "Result="REM WinXP doesn't support TN for schtasks /queryFOR /F "delims=, tokens=2" %%R IN ('schtasks /query /fo csv /v ^| findstr /L /C:"%TaskName%"') DO SET Result=%%RIF (%Result%)==() SET Result="-1"IF "%TaskName%" == %Result% (REM Delete Task if it exists               SCHTASKS /Delete /TN "%TaskName%" /F)REM Then Create on Logon running oneSCHTASKS /Create /TN "%TaskName%" /TR "%Task%" /SC ONLOGON /RL HIGHESTGOTO exit:ver_vista:Run Windows Vista specific commands here.GOTO Elevation:ver_7:Run Windows 7 specific commands here.GOTO Elevation:ElevationREM Don't forget escape double quotes for CMD argument that you will pass to powershellPushD "%~dp0"IF EXIST "%~0.ELEVATED" DEL /F "%~0.ELEVATED"SET Argument=SCHTASKS /Create /F /TN \"%TaskName%\" /TR \"%Task%\" /SC ONLOGON /RL HIGHESTSET ELEVATED_CMD=PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('Cmd.exe', '/C %Argument%', '', 'runas')ECHO %ELEVATED_CMD% >> "%~0.ELEVATED"CALL %ELEVATED_CMD%DEL /F "%~0.ELEVATED"PopDGOTO exit:exitEXIT

 
All shorcuts are working also fine.
Many thanks
 
Regards

 

*Edit: batch file updated to disable XP section (::ver_xp) because installation fails

post-23163-0-19403600-1359791518_thumb.p

Edited by myselfidem

Share this post


Link to post
Share on other sites

NOTE: I wrote this before I saw the last post by myselfidem.  I made notations accordingly, but if I missed something please forgive me.

 
Geej & myselfidem,
 
As I mentioned previously, I've got some issues with "Everything_Schedule.bat" as included in the file you last posted Geej.  (NOTE: You caught some of the errors myselfidem, but not all. :) )  It simply does not work correctly.  It looks as if someone cut-and-pasted from a couple of different sources, and not very well.  For reference, you can check out the original script http://myunster.com/blog/server-administration/30.html#comment16'>http://myunster.com/blog/server-administration/30.html#comment16 and compare that to the code as I extracted it from EverythingSearchEngine_1.3.0.632bSi.exe:
 

::*******************************************:::: schedule.bat                              :::: Set variables TaskName, Task and go ahed  :::: http://myunster.com                       ::::*******************************************::@ECHO offECHO "Proceeding..." REM Delete variables, may be cachedSET "TaskName="SET "Task=" REM Set variablesSET TaskName=DummyTaskNameREM Following task will be executed every hourSET Task=C:\www.domain.dev\usr\local\php5\php.exe C:\www.domain.dev\cron.php REM Determine if windows xpVER | find "XP" > NULIF %ERRORLEVEL% == 0 GOTO ver_xp REM Determine if windows Vista/Win7systeminfo | find "OS Name" > %TEMP%\osname.txtFOR /F "usebackq delims=: tokens=2" %%i IN (%TEMP%\osname.txt) DO SET Version=%%iDEL /F %TEMP%\osname.txt ECHO %Version% | find "Windows 7" > NULIF %ERRORLEVEL% == 0 GOTO ver_7ECHO %Version% | find "Windows Vista" > NULIF %ERRORLEVEL% == 0 GOTO ver_vista :ver_xp:Run Windows XP specific commands here.REM Delete variable, may be cachedSET "Result="REM WinXP doesn't support TN for schtasks /queryFOR /F "delims=, tokens=2" %%R IN ('schtasks /query /fo csv /v ^| findstr /L /C:"%TaskName%"') DO SET Result=%%RIF (%Result%)==() SET Result="-1"IF "%TaskName%" == %Result% (REM Delete Task if it exists        SCHTASKS /Delete /TN "%TaskName%" /F)REM Then Create hourly running oneSCHTASKS /Create /TN "%TaskName%" /TR "%Task%" /SC HOURLY /RU SYSTEMGOTO exit :ver_vista:Run Windows Vista specific commands here.GOTO Elevation :ver_7:Run Windows 7 specific commands here.GOTO Elevation :ElevationREM Don't forget escape double quotes for CMD argument that you will pass to powershellPushD "%~dp0"IF EXIST "%~0.ELEVATED" DEL /F "%~0.ELEVATED"SET Argument=SCHTASKS /Create /F /TN \"%TaskName%\" /TR \"%Task%\" /SC HOURLY /RU SYSTEMSET ELEVATED_CMD=PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('Cmd.exe', '/C %Argument%', '', 'runas')ECHO %ELEVATED_CMD% >> "%~0.ELEVATED"CALL %ELEVATED_CMD%DEL /F "%~0.ELEVATED"PopDGOTO exit :exitECHO "Done!"EXIT

 
From EverythingSearchEngine_1.3.0.632bSi.exe:

::*******************************************:::: Everything_Schedule.bat                   :::: Set variables TaskName, Task and go ahead :::: http://myunster.com                       ::::*******************************************::@ECHO offECHO "Proceeding..." >NUL REM Delete variables, may be cachedSET "TaskName="SET "Task="REM Set variablesSET TaskName=EverythingREM Following task will be executed on LogonIF EXIST "%SystemRoot%\SysWOW64\cmd.exe" GOTO :X64:X64SET Task=\"%%ProgramFiles(x86)%%\Everything\Everything.exe\" -startup IF NOT EXIST "%SystemRoot%\SysWOW64\cmd.exe" GOTO :x86:x86SET Task=\"%%ProgramFiles%%\Everything\Everything.exe\" -startupREM Determine if windows xpVER | find "XP" > NULIF %ERRORLEVEL% == 0 GOTO ver_xpREM Determine if windows Vista/Win7systeminfo | find "OS Name" > %TEMP%\osname.txtFOR /F "usebackq delims=: tokens=2" %%i IN (%TEMP%\osname.txt) DO SET Version=%%iDEL /F %TEMP%\osname.txtECHO %Version% | find "Windows 7" > NULIF %ERRORLEVEL% == 0 GOTO ver_7ECHO %Version% | find "Windows Vista" > NULIF %ERRORLEVEL% == 0 GOTO ver_vista:ver_xp:Run Windows XP specific commands here.REM Delete variable, may be cachedSET "Result="REM WinXP doesn't support TN for schtasks /queryFOR /F "delims=, tokens=2" %%R IN ('schtasks /query /fo csv /v ^| findstr /L /C:"%TaskName%"') DO SET Result=%%RIF (%Result%)==() SET Result="-1"IF "%TaskName%" == %Result% (REM Delete Task if it exists                SCHTASKS /Delete /TN "%TaskName%" /F)REM Then Create hourly running oneSCHTASKS /Create /TN "%TaskName%" /TR "%Task%" /SC ONLOGON /RL HIGHESTGOTO exit:ver_vista:Run Windows Vista specific commands here.GOTO Elevation:ver_7:Run Windows 7 specific commands here.GOTO Elevation:ElevationREM Don't forget escape double quotes for CMD argument that you will pass to powershellPushD "%~dp0"IF EXIST "%~0.ELEVATED" DEL /F "%~0.ELEVATED"SET Argument=SCHTASKS /Create /F /TN \"%TaskName%\" /TR \"%Task%\" /SC ONLOGON /RL HIGHESTSET ELEVATED_CMD=PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('Cmd.exe', '/C %Argument%', '', 'runas')ECHO %ELEVATED_CMD% >> "%~0.ELEVATED"CALL %ELEVATED_CMD%DEL /F "%~0.ELEVATED"PopDGOTO exit:exitECHO "Done!"EXIT

 
 
I'll list the problems I see in order.
 
-- 1)
 
REM Following task will be executed on LogonIF EXIST "%SystemRoot%\SysWOW64\cmd.exe" GOTO :X64:X64SET Task=\"%%ProgramFiles(x86)%%\Everything\Everything.exe\" -startup IF NOT EXIST "%SystemRoot%\SysWOW64\cmd.exe" GOTO :x86:x86SET Task=\"%%ProgramFiles%%\Everything\Everything.exe\" -startup
[NOTE: You caught this myselfidem, but I'm afraid your correction is not quite right.]
 
This does not work correctly.  The IF statements do not do anything at all.  The last SET Task statement will get executed every time no matter what.  So Task will be equal to -- \"%%ProgramFiles%%\Everything\Everything.exe\" -startup -- for both x86 and x64 systems.  Also, the test for x86/x64, IF it was properly executed, will probably work OK in most situations, but it is not as robust a test as it could be.  (See here - http://www.ryanvm.net/forum/viewtopic.php?t=9672'>http://www.ryanvm.net/forum/viewtopic.php?t=9672 - for a full discussion.)  That section of code could be rewritten as:
 
SET Task=\"%%ProgramFiles(x86)%%\Everything\Everything.exe\" -startupIF NOT EXIST "%SystemRoot%\SysWOW64\cmd.exe" (    IF NOT DEFINED PROCESSOR_ARCHITEW6432 SET Task=\"%%ProgramFiles%%\Everything\Everything.exe\" -startup)
but I would probably rewrite it as:
 
(SET "Tsk=(x86)") & (IF NOT EXIST "%SystemRoot%\SysWOW64\cmd.exe" (    IF NOT DEFINED PROCESSOR_ARCHITEW6432 (SET "Tsk=")))SET Task=\"%%ProgramFiles%Tsk%%%\Everything\Everything.exe\" -startup
 
-- 2)
 
You next have two lines that are run together:  [NOTE: You caught this myselfidem, good job!]
 
REM Determine if windows xpVER | find "XP" > NUL
This causes the "VER" test to never be executed.  As a result, the next line:
 
IF %ERRORLEVEL% == 0 GOTO ver_xp
causes my Win7 x64 system to be identified as XP and the rest of the version checking code to be skipped completely.  I would expect that this is happening to you as well, myselfidem.  In fact, from what I can tell, thanks to this error and error (II), every system will be identified as a 32-bit XP system.  The Powershell commands listed at the bottom of the batch will never be executed.  I guess this is just as well for Vista users, since if the version checking code was executed on a Vista system it would fail because you have another two lines run together at the end of the "XP Section" of code:  [NOTE: You missed this one myselfidem.]
 
GOTO exit:ver_vista
The result of this is that the :ver_vista label doesn't exist as far as this batch is concerned so the code will fail and cause an execution error with an error box that the user will have to respond to in order to clear it.
 
 
-- 3)
 
Even if the run together lines were fixed, the version checking code takes a looong time for OS > XP, is more complicated than necessary, and Win 8 will be treated as XP, since all versions except Win 7 and Vista will be treated as XP.  [As noted above, I think EVERYTHING is treated as if it was XP right now, ie I don't see how the Powershell code can possibly be executed.]  For that matter, both Win 7 and Vista are treated the same so the extra tests to identify Vista are not necessary.  Best I can tell, the only real reason to do an OS Version check is to see if it is Vista or above so that Powershell can be utilized, correct?  Well, what if Powershell is not installed or has been removed?  And Powershell can be added to XP, right?  So, bottom line, there is no way to really tell if Powershell is present without checking for it, so you might as well just do that.  Isn't that a better approach?  Assuming that is a better approach, and based off info I found here - http://blogs.msdn.com/b/powershell/archive/2009/06/25/detection-logic-poweshell-installation.aspx'>http://blogs.msdn.com/b/powershell/archive/2009/06/25/detection-logic-poweshell-installation.aspx - I would replace the version checking code with this:
 
REM Check for PowesrshellSTART "Get Windows Version" /WAIT REGEDIT /E "%TEMP%.\_Temp.reg" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1"IF EXIST "%TEMP%.\_Temp.reg" (    FOR /F "tokens=1* delims=:" %%G IN ('TYPE "%TEMP%.\_Temp.reg" ^| FIND /I "Install"') DO (        (SET /A "_PSInstalled=%%H") & (IF "!_PSInstalled!"=="1" GOTO:psFound)    )) REM ps NOT foundREM put the old "XP" code hereGOTO:exit :psFoundREM put the old "Elevation" code hereGOTO:exit
If you really need to check for OS version, a much quicker way than "systeminfo" is to use the command "VER".  See here - http://ss64.com/nt/ver.html'>http://ss64.com/nt/ver.html - for a discussion.  Again, since in this instance it seems you only care if it is XP (or below?), or above XP, I would shorten it this way:
 
FOR /F "tokens=2 delims=[]" %%G IN ('VER') DO (SET "_WinVer=%%G")FOR /F "tokens=2 delims=. " %%G IN ('ECHO %_WinVer%') DO (SET "_Major=%%G")IF "%_Major%"=="6" GOTO:aboveXP REM do your XP stuff hereGOTO:restOfStuff :aboveXPREM do your above XP stuff here :restOfStuffREM do anything else that pertains to all OS here
 
EDIT: I was reminded by myselfidem that even if Powershell had been added to XP, that the commands for dealing with SCHTASKS are slightly different for XP vs Vista/7, so the two methods above have been combined in the full code shown below like this:
 
REM Check for XPFOR /F "tokens=2 delims=[]" %%G IN ('VER') DO (SET "_WinVer=%%G")FOR /F "tokens=2 delims=. " %%G IN ('ECHO %_WinVer%') DO (IF "%%G"=="5" GOTO:treatAsXP)REM Check for Powershell in case it was uninstalledSTART "Get Windows Version" /WAIT REGEDIT /E "%TEMP%.\_Temp.reg" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1"IF EXIST "%TEMP%.\_Temp.reg" (    FOR /F "tokens=1* delims=:" %%G IN ('TYPE "%TEMP%.\_Temp.reg" ^| FIND /I "Install"') DO (        (SET /A "_PSInstalled=%%H") & (IF "!_PSInstalled!"=="1" GOTO:psFound)    )) :treatAsXPREM do your XP stuff hereGOTO:exit :psFound - old "Elevation" codeREM do your above XP stuff hereGOTO:exit
Note that the Powershell tests are still useful in case Powershell has been removed from the OS, as some folks have done in attempts to "slim" Win 7.
 
 
-- 4)
 
I was mainly concerned with the Batch command errors as I saw them.  My resulting revised code is:
 

@ECHO OFF & SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION::***********************************************************:::: Everything_Schedule.bat                                   :::: Sets variables _Schedule, _TaskName, _Task and goes ahead :::: Original script from: http://myunster.com                 :::: Modified by bphlpt 2013-02-05                             ::::***********************************************************::CALL :sub_CleanUp REM Set Task specific variables - %ProgramFiles% will be used if OS is 32-bit, %ProgramFiles(x86)% if OS is 64-bit(SET "_Schedule=ONLOGON")(SET "_TaskName=Everything")(SET "_X86=(x86)") & (IF NOT EXIST "%SystemRoot%\SysWOW64\cmd.exe" (IF NOT DEFINED PROCESSOR_ARCHITEW6432 (SET "_X86=")))(SET _Task=\"%%ProgramFiles%_X86%%%\Everything\Everything.exe\" -startup) REM Check if OS is XP, if it is not XP then check for PowerShell in case it was uninstalledFOR /F "tokens=2 delims=[]" %%G IN ('VER') DO (SET "_WinVer=%%G")FOR /F "tokens=2 delims=. " %%G IN ('ECHO %_WinVer%') DO (IF "%%G"=="5" GOTO:treatAsXP)START "Get Windows Version" /WAIT REGEDIT /E "%TEMP%.\_Temp.reg" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1"IF EXIST "%TEMP%.\_Temp.reg" (FOR /F "tokens=1* delims=:" %%G IN ('TYPE "%TEMP%.\_Temp.reg" ^| FIND /I "Install"') DO (    (SET /A "_PSInstalled=%%H") & (IF "!_PSInstalled!"=="1" GOTO:psFound))) :treatAsXPREM or PowerShell NOT found - using FINDSTR is necessary since WinXP does not support TN for schtasks /query(SET _Result="-1") & FOR /F "delims=, tokens=2" %%R IN ('SCHTASKS /query /fo csv /v ^| FINDSTR /L /C:"%_TaskName%"') DO (SET _Result=%%R)IF "%_TaskName%"==%Result% (SCHTASKS /Delete /TN "%_TaskName%" /F)SCHTASKS /Create /TN "%_TaskName%" /TR "%_Task%" /SC %_Schedule% /RL HIGHESTGOTO:exit :psFoundREM Do not forget to escape any double quotes in CMD arguments that you will pass to PowerShellSET _Argument=SCHTASKS /Create /TN \"%_TaskName%\" /TR \"%_Task%\" /SC %_Schedule% /RL HIGHEST /FSET _ELEVATED_CMD=PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('Cmd.exe', '/C %_Argument%', '', 'runas')PushD "%~dp0"DEL /F "%~0.ELEVATED" >NUL 2>&1ECHO %_ELEVATED_CMD% >"%~0.ELEVATED"CALL %_ELEVATED_CMD%DEL /F "%~0.ELEVATED" >NUL 2>&1PopDGOTO:exit :sub_CleanUpREM Clean up any leftover files or variablesDEL "%TEMP%.\_Temp.reg" >NUL 2>&1FOR /F "tokens=1* delims==" %%G IN ('"SET "_" 2>nul"') DO (SET "%%G=")EXIT /B 0 :exitCALL :sub_CleanUpENDLOCAL & EXIT

 
Please note that I have changed all variable names to begin with "_".
 
I've never used either the "SCHTASKS" command or Powershell, so I left the code alone that dealt with them other than a very slight "cleaning up".  Someone else really needs to double check this code to make sure it functions correctly in all circumstances.  For example, I don't understand the purpose of this:
 
IF EXIST "%~0.ELEVATED" DEL /F "%~0.ELEVATED"...ECHO %_ELEVATED_CMD% >> "%~0.ELEVATED"CALL %_ELEVATED_CMD%DEL /F "%~0.ELEVATED"
Unless Powershell uses it in some way, I don't see that "%~0.ELEVATED" is ever used, just created and deleted.  Did I miss something?  I figure it must be for handling UAC if enabled, but I don't know how it works.  If it is not needed, it seems like that could be changed to just:
 
...CALL %_ELEVATED_CMD%
 
I hope all this makes sense.  My final code has been very MINIMALLY tested.  Please comment and ask for clarification if needed.
 
Cheers and Regards
Edited by bphlpt

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×