Nexus_06 Posted August 29, 2009 Posted August 29, 2009 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
HØLLØW Posted September 16, 2009 Posted September 16, 2009 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%"
ckislam Posted September 17, 2009 Posted September 17, 2009 (edited) 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, 2009 by ckislam
Yzöwl Posted September 17, 2009 Posted September 17, 2009 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!
jaclaz Posted September 17, 2009 Posted September 17, 2009 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
strel Posted September 17, 2009 Posted September 17, 2009 (edited) Something like this is what I suppose Yzöwl is talking about. Edited September 17, 2009 by strel
jaclaz Posted September 17, 2009 Posted September 17, 2009 (edited) 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, 2009 by jaclaz
Yzöwl Posted September 17, 2009 Posted September 17, 2009 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=)
ckislam Posted September 17, 2009 Posted September 17, 2009 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
Yzöwl Posted September 17, 2009 Posted September 17, 2009 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.
ckislam Posted September 17, 2009 Posted September 17, 2009 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%)
Yzöwl Posted September 18, 2009 Posted September 18, 2009 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.
jaclaz Posted September 18, 2009 Posted September 18, 2009 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
Dumpy Dooby Posted September 19, 2009 Posted September 19, 2009 (edited) 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, 2009 by Dumpy Dooby
Yzöwl Posted September 20, 2009 Posted September 20, 2009 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=%*)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now