开发者

Get the OS information if server 2003 then run the script

I have a .bat script that I created yesterday. I now need to开发者_运维问答 find the OS name or a remote server and if its server 2003 64bit = true then run test.bat Is there an easy way to do this?

Heres the script I want to run:

 If OS = Server 2003 
 Then 
 psexec -u domain\user -p password \\@serverlist -s -i -d
 msiexec.exe /i "\\share\folder\Avmr64.msi" /qb

I am finding several ways to get the info but how would I add an if statement in there?


One way you can test for a 64-bit system, without getting too technical, is to check for the C:\program files (x86)\ directory. In a 32-bit system, it's just C:\Program Files. This directory does also exist on 64-bit systems, so the absence of the C:\Program Files (x86)\ tells you it's 32-bit.

The third line of this batch file will run if the directory exists, if it doesn't exist, it goes to the :NoUse32bitVersion label.

C:
IF NOT EXIST "C:\Program Files (x86)\" GOTO IS32BIT
psexec -u domain\user -p password \\@serverlist -s -i -d msiexec.exe /i "\\share\folder\Avmr64.msi" /qb
:IS32BIT
echo Put your 32-bit version of the code here (or just EXIT)


ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003

ver | find "some other os string" > nul
if %ERRORLEVEL% == 0 goto some_other_os

:ver_2003 your 2003 specific code here

Replace "some other os string" with meaningful string to get info about other os's if you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜