How to make script run a command based .txt

November 15, 2010 at 11:09:02
Specs: Windows Vista
i am trying to make a script that will pull certain info from the computer and log it in a .txt and then based on what it logged run 1 of 3 different scripts i have made. What i dont know how to do is make the cript log info into a .txt and then call on the info inside of the .txt later on.

an example would be for it to look at the service pack of the current system log in a .txt and then based on which one it logged run the update i have set up.

See More: How to make script run a command based .txt

Report •

November 19, 2010 at 10:14:38
if you using command (Batch mode) then you can use > filename.txt or >filename.log

like systeminfo >C:\abc.txt

Subhash Chandra.

Report •

November 19, 2010 at 11:37:35
ok now how could i call on that specific info inside the log or txt file like if it logs that the sytem is runnin service pack 1 to run the service pack 2 update i have configured for my network

Report •

November 19, 2010 at 12:04:24
what exactly you are trying to do ? and if you are querying the Service pack version then from where ?

are you getting service pack info from registry or from systeminfo command or somwhere else?

An example would be using systeminfo command..

systeminfo >C:\temp\sysinfo.txt
findstr /i /c:"OS Version:" C:\temp\sysinfo.txt

output of above would be something like below.

OS Version: 5.1.2600 Service Pack 3 Build 2600

now you can parse the output of findstr to get your exact value. Like

If servicepack value is 1 or 2 do your command.

Subhash Chandra.

Report •

Related Solutions

November 19, 2010 at 12:09:45
the update to service pack is another script i have created but i only want it to run if the computer is on service pack 2 if the system is currently service pack 1 i want it to give me a pop up and i already know how to do that what i didnt know is how to make it log the system info then search in that log file to see what service pack it was so that way it could either run my update i have or give me my pop up

Report •

November 19, 2010 at 12:45:45
you didn't answered the first questions that how you r finding the system info.ANyway I will use registry to get the info here.

@echo off
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" | findstr "CSDVersion" >%temp%\2.txt
for /f "tokens=3 delims= " %%a in (%temp%\2.txt) do (set sp=%%a)
erase /f %temp%\2.txt
if %sp% ==2 goto sp2
if NOT %sp% ==2 goto sp_other

echo I m in Sp2.
echo (Call your script from here.)

Echo Your system is currently running with Service Pack %sp%.
echo This is a notification that you r not runnig on SP2.

Let me know if you have questions.

Subhash Chandra.

Report •

Ask Question