August 29, 200916 yr I have several things packaged up for 2k/XP , but now I want to make them work also on Windows7. I have some questions...For instance, I have a sfx which I created which contains stuff I copy to system32... this pack contains sysinternals tools and some from other sites. It also copies shortcuts and help files to the proper directories.for my paths I have say...%windir%\system32\%windir%\help\%allusersprofile%\start menu\programs\accessories\system tools\I know that win7 (and vista) has protection on these folders, how can I take temporary control of them to copy the needed files?also is there a way I can integrate the scripts into one script, which detects which OS it is being run on, and branch to the different routines if needed?any help appreciated
September 16, 200916 yr I don't know if this works on Windows 7, but you can use the following command in a .cmd-file to get access to the folder:ATTRIB -R "%YOUR FOLDER%"
September 17, 200916 yr one script, which detects which OS it is being run on..To Detect Windows version from the command line use the VER command, with find and errorlevels you can then redirect your commandsExample for usage:VER | FIND.exe /i "xp" >NULif %errorlevel%==0 ECHO You are using XP..to identify x86 and x64 CPU, use the variable %processor_architecture%also see this:http://support.microsoft.com/kb/556009I hope this helps Edited September 17, 200916 yr by ckislam
September 17, 200916 yr To Detect Windows version from the command line use the VER commandTechnically incorrect, this will detect the version of the Command Interpreter not that of Windows!
September 17, 200916 yr Nicely put here:http://ss64.com/nt/ver.htmlBugsThe VER command reports the version of CMD.exe, so if for example you run the Win XP version of CMD under NT 4 then the VER command will return:Microsoft Windows XP [Version 4.0.1381]Though I guess that is "good enough" for "normal" use.I guess the "proper" way is to check the %OS% varaible, than check contents of this Registry key:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion ProductNameCurrentBuildNumberCurrentVersionShould contain all the needed data (that can be compared with the VER results)jaclaz
September 17, 200916 yr Something like this is what I suppose Yzöwl is talking about. Edited September 17, 200916 yr by strel
September 17, 200916 yr Something like this is what I suppose Yzöwl is talking about.You mean the thread where Aegis says to check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion ? From batch/command line one can use WMIC allright, some examples:WMIC OS list /Format:listWMIC OS list BRIEF /Format:listWMIC OS get /Format:listWMIC OS get name, version /Format:listjaclaz Edited September 17, 200916 yr by jaclaz
September 17, 200916 yr Here's a method I've used which should always work, (unless your crazy enough to have disabled the workstation service)!ThisOS.cmd@Echo off&Setlocal enableextensionsFor /f "delims=" %%# In ('Net config work^|Find /i " Windows "') Do Call :OSis %%#If Defined HostOS (Echo Detected OS is Windows %HostOS%) Else ( Echo Host OS not Detected!)Pause&Goto :Eof:OSisEcho %*|Find "2000">Nul 2>&1&&(Set "HostOS=2000"&Goto :Eof)Echo %*|Find "2002">Nul 2>&1&&(Set "HostOS=XP"&Goto :Eof)Echo %*|Find "2003">Nul 2>&1&&(Set "HostOS=2003"&Goto :Eof)Echo %*|Find "Vista">Nul 2>&1&&(Set "HostOS=Vista"&Goto :Eof)Echo %*|Find "2008">Nul 2>&1&&(Set "HostOS=2008"&Goto :Eof)Echo %*|Find "7">Nul 2>&1&&(Set "HostOS=7"&Goto :Eof)(Set HostOS=)
September 17, 200916 yr Technically incorrect, this will detect the version of the Command Interpreter not that of Windows!May be you should try this:ver /?Displays the Windows versionI get this:at XP: Microsoft Windows XP [Version 5.1.2600]at 7: Microsoft Windows [Version 6.1.7600]Also stated at microsoft documentation:http://www.microsoft.com/resources/documen...r.mspx?mfr=trueVerDisplays the Windows XP version number.How did you find out that it detects the command Interpreter version not that windows?!Funny that microsoft was mistaken Anyhow you know it better than them Thanks
September 17, 200916 yr It is a fact, VER gives the version of the command interpreter!Microsoft's documentation assumes that end users will not replace executables with versions from earlier or later Operating Systems, hence they don't produce documentation to cover such an eventuality.If you wish be proven incorrect, please try swapping XP and Windows 2000 cmd.exe's or even different SP levels of CMD.EXE and run the command in each.
September 17, 200916 yr Here's a method I've used which should always work, (unless your crazy enough to have disabled the workstation service)!ThisOS.cmd@Echo off&Setlocal enableextensionsFor /f "delims=" %%# In ('Net config work^|Find /i " Windows "') Do Call :OSis %%#If Defined HostOS (Echo Detected OS is Windows %HostOS%) Else ( Echo Host OS not Detected!)Pause&Goto :Eof:OSisEcho %*|Find "2000">Nul 2>&1&&(Set "HostOS=2000"&Goto :Eof)Echo %*|Find "2002">Nul 2>&1&&(Set "HostOS=XP"&Goto :Eof)Echo %*|Find "2003">Nul 2>&1&&(Set "HostOS=2003"&Goto :Eof)Echo %*|Find "Vista">Nul 2>&1&&(Set "HostOS=Vista"&Goto :Eof)Echo %*|Find "2008">Nul 2>&1&&(Set "HostOS=2008"&Goto :Eof)Echo %*|Find "7">Nul 2>&1&&(Set "HostOS=7"&Goto :Eof)(Set HostOS=)Make it simple (in one line) FOR %%i in (2000 2002 2003 Vista 2008 7) DO NET CONFIG WORK|Find "%%i">Nul 2>&1&&(Set "HostOS=%%i"&ECHO %HOSTOS%)
September 18, 200916 yr Make it simple (in one line) FOR %%i in (2000 2002 2003 Vista 2008 7) DO NET CONFIG WORK|Find "%%i">Nul 2>&1&&(Set "HostOS=%%i"&ECHO %HOSTOS%)It would be nice if that worked for all, however I think that expecting, for instance 7, not to appear in any line of the 'net config' output other than the Software version one is asking a little too much! Also outputting 2002 to an XP user may confuse them. The other niggle I'd have is that you will be running the more intensive 'net config' command six times as opposed to one.
September 18, 200916 yr I may add that a User Name like:Windows 2000orUser 2002may trick the oneliner, whilst it does not trick the original one by Yzöwl jaclaz
September 19, 200916 yr Windows XP ProfessionalFOR /f %%A in ('wmic os get name^, version /format:list') Do Set %%AI'm not sure if that will work on Vista or Windows 7. But anyone using either of those should consider upgrading to Windows XP anyway. Edited September 19, 200916 yr by Dumpy Dooby
September 20, 200916 yr If I was to use Wmic for this, I'd probably use this:@Echo off & Setlocal enableextensionsFor /F "tokens=1* delims==" %%a In ('Wmic OS Get Caption /value^|Find "="') Do ( Call :_ %%b)Echo %%HostOs%%=%HostOs%Ping -n 6 127.0.0.1 > Nul & Goto :Eof:_(Set HostOs=%*)
Create an account or sign in to comment