sammy65
Goto Top

If Abfrage in Batchdatei

Hallo miteinander,

ich möchte eine cfg.Datei in ein Verzeichnis kopieren.
Da ich sowohl Windows 7 32 bit und 64 Bit Clients habe muss zuvor abgefragt werden ob die Verzeichnisste existieren.

@echo off
if exist C:\Windows\SysWOW64\Macromed\Flash\*.* Goto Win64
if exist C:\Windows\System32\Macromed\Flash\*.* Goto Win32

:Win64
xcopy mms.cfg C:\Windows\SysWOW64\Macromed\Flash\ /Y

:Win32
xcopy mms.cfg C:\Windows\System32\Macromed\Flash\ /Y

Ist das so korrekt?

Content-Key: 251843

Url: https://administrator.de/contentid/251843

Printed on: April 25, 2024 at 23:04 o'clock

Member: Snowman25
Snowman25 Oct 14, 2014 at 07:57:25 (UTC)
Goto Top
Hallo @sammy65,

ja und nein.

Die IF-Abfragen an sich sind korrekt, jedoch musst du moehr mit Labels arbeiten.
Beispiel: erstes IF ist TRUE. Win64 wird ausgeführt, dann Win32.
echo off
IF exist C:\Windows\SysWOW64\Macromed\Flash\*.* GOTO Win64
IF exist C:\Windows\System32\Macromed\Flash\*.* GOTO Win32
ECHO Kein Flash installiert!
GOTO :EOF

:Win64
XCOPY mms.cfg C:\Windows\SysWOW64\Macromed\Flash\ /Y
GOTO :EOF

:Win32
XCOPY mms.cfg C:\Windows\System32\Macromed\Flash\ /Y
GOTO :EOF

Gruß,
@Snowman25
Member: sammy65
sammy65 Oct 14, 2014 at 12:06:25 (UTC)
Goto Top
Hallo Snowman25,

Vielen Dank für Deine Mühe.

Kann ich die so jetzt verwenden?
Oder muss ich noch was verändern?

Ich bin nicht so der Programmiergott....
Member: sammy65
sammy65 Oct 15, 2014 updated at 06:39:55 (UTC)
Goto Top
Hi,

es klappt nicht so ich es mir vorstelle. die Datei mms.cfg wird auf alle 64 bit clients kopiert auf den 32 bit nicht. Was mache ich denn noch falsch?

Die Batch sieht jetzt so aus:

@echo off
IF exist C:\Windows\SysWOW64\Macromed\Flash\*.* GOTO Win64
IF exist C:\Windows\System32\Macromed\Flash\*.* GOTO Win32
ECHO Kein Flash installiert!
GOTO :EOF


:Win64
XCOPY mms.cfg C:\Windows\SysWOW64\Macromed\Flash\ /Y
GOTO :EOF

:Win32
XCOPY mms.cfg C:\Windows\System32\Macromed\Flash\ /Y
GOTO :EOF

lg
Thomas
Member: sammy65
sammy65 Oct 16, 2014 at 06:45:28 (UTC)
Goto Top
Kann mir niemand helfen, die Datei wird auf meinen 32 bit Clients nicht kopiert.
Member: Snowman25
Snowman25 Oct 22, 2014 at 08:09:15 (UTC)
Goto Top
Hallo @sammy65,

entschuldige, ich war letzte Woche krank.

Ich empfehle dir, auf die Existenz eines Verzeichnisses so zu prüfen:
IF EXIST C:\Windows\system32\Macromed\Flash\NUL

In meiner Umgebung kopiere ich die mms.cfg nicht über Batch, sondern per AutoHotkey-Script. Dabei wird die Entscheidung zwischen SysWOW64 und system32 vom Betriebssystem durchgeführt. Dies scheint in Batch leider nicht zu funktionieren.

WAS funktioniert denn nicht in deinem Skript?
Schonmal Echo off auskommentiert und ein paar ECHOs im Code verteilt?

Gruß,
@Snowman25
Member: sammy65
sammy65 Oct 31, 2014 at 11:52:52 (UTC)
Goto Top
Ich habs jetzt so gelöst, funktioniert einwandfrei....
Untenstehendes Batch führe ich via GPO als Startscript aus.....

REM ------------------------------------------------------------
REM Konfigurationsdatei mms.cfg erstellen
REM ------------------------------------------------------------

SET x86path=%WINDIR%\System32\Macromed\Flash
SET x64path=%WINDIR%\SysWOW64\Macromed\Flash

SET RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% | Find /i "x86"
If %ERRORLEVEL% == 0 (
GOTO X86
) ELSE (
GOTO X64
)

:X86
echo x86
if exist %x86path% echo AutoUpdateDisable = 1 > %x86path%\mms.cfg
goto END

:X64
echo x64
if exist %x64path% echo AutoUpdateDisable = 1 > %x64path%\mms.cfg
goto END


:END

REM ------------------------------------------------------------
REM Konfigurationsdatei mms.cfg erstellen
REM ------------------------------------------------------------