MikeC

Running a CMD Command with Many Parameters

7 posts in this topic

#1 ·  Posted

Hi

I am trying to run the following commands and after literally hours of google searches over multiple days, I cannot get them to run.

if not exist %WinDir%\System32\Macromed\Flash\ md %WinDir%\System32\Macromed\Flash\
if not exist %WinDir%\SysWow64\Macromed\Flash\ md %WinDir%\SysWow64\Macromed\Flash\
echo AutoUpdateDisable=1 >%WinDir%\System32\Macromed\Flash\mms.cfg
echo AutoUpdateDisable=1 >%WinDir%\SysWow64\Macromed\Flash\mms.cfg

For example, this returns a zero, but does not run the required command:

Run(@ComSpec & " /c " & 'if not exist %WinDir%\System32\Macromed\Flash\ md %WinDir%\System32\Macromed\Flash\', @SW_HIDE)

Please can someone help me out?

Share this post


Link to post
Share on other sites



#2 ·  Posted

@MikeC I would suggest just doing what you want to do in AutoIt, rather than trying to do it in a batch file and then run the batch through AutoIt; save yourself a lot of headache. The syntax is very similar (below):

If Not (FileExists(@WindowsDir & "\System32\Macromed\Flash\")) Then DirCreate(@WindowsDir & "\System32\Macromed\Flash\")

You can then use AutoIt to modify the mms.cfg to add your AutoUpdateDisable.

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

Here is the code I used for packaging Adobe Flash config

Opt('ExpandVarStrings', 1)
FNC_FLASHCFG()
Func FNC_FLASHCFG()
    Local $hCFG_AdobeFlash = '@WindowsDir@\System32\macromed\Flash\mms.cfg'
    Local $hOPN_AdobeFlash = FileOpen($hCFG_AdobeFlash, 138)
    FileWrite($hOPN_AdobeFlash, 'AutoUpdateDisable=1' & @CRLF)
        If @OSVersion = 'WIN_XP' Then FileWrite($hOPN_AdobeFlash, 'AutoUpdateInterval=0' & @CRLF)
    FileClose($hOPN_AdobeFlash)
EndFunc

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

1 hour ago, JLogan3o13 said:

@MikeC I would suggest just doing what you want to do in AutoIt, rather than trying to do it in a batch file and then run the batch through AutoIt; save yourself a lot of headache. The syntax is very similar (below):

If Not (FileExists(@WindowsDir & "\System32\Macromed\Flash\")) Then DirCreate(@WindowsDir & "\System32\Macromed\Flash\")

You can then use AutoIt to modify the mms.cfg to add your AutoUpdateDisable.

Error:

 

"If" statement  has no matching "EndIf" statement

Share this post


Link to post
Share on other sites

#5 ·  Posted

53 minutes ago, Subz said:

Here is the code I used for packaging Adobe Flash config

Opt('ExpandVarStrings', 1)
FNC_FLASHCFG()
Func FNC_FLASHCFG()
    Local $hCFG_AdobeFlash = '@WindowsDir@\System32\macromed\Flash\mms.cfg'
    Local $hOPN_AdobeFlash = FileOpen($hCFG_AdobeFlash, 138)
    FileWrite($hOPN_AdobeFlash, 'AutoUpdateDisable=1' & @CRLF)
        If @OSVersion = 'WIN_XP' Then FileWrite($hOPN_AdobeFlash, 'AutoUpdateInterval=0' & @CRLF)
    FileClose($hOPN_AdobeFlash)
EndFunc

 

Thanks.

I have no knowledge or experience of functions in AIT; What does line 1 do exactly?

What does line 2 do? I can see that you define the function in line 3, does 2 simply execute it?

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

;~ Expands Variables within a string for example:
;~ '@WindowsDir@\...' = 'C:\Windows\...'
Opt('ExpandVarStrings', 1)
;~ Runs the function
FNC_FLASHCFG()
;~ Declares the function
Func FNC_FLASHCFG()
     ;~ Adobe Flash configuration path
    Local $hCFG_AdobeFlash = '@WindowsDir@\System32\macromed\Flash\mms.cfg'
    ;~ Opens '@WindowsDir@\System32\macromed\Flash\mms.cfg' for writing 
    ;~ Flag: 138
    ;~      : 128 Use Unicode UTF8 (with BOM) (Adobe requirement)
    ;~      : 8 Create directory structure if it doesn't exist
    ;~      : 2 Write mode (overwrite previous contents)
    Local $hOPN_AdobeFlash = FileOpen($hCFG_AdobeFlash, 138)
    ;~ Write AutoUpdateDisable=1 to the file
    FileWrite($hOPN_AdobeFlash, 'AutoUpdateDisable=1' & @CRLF)
        ;~ If Windows XP Write AutoUpdateInerval=0 to the file
        If @OSVersion = 'WIN_XP' Then FileWrite($hOPN_AdobeFlash, 'AutoUpdateInterval=0' & @CRLF)
    ;~ Close/Save the file
    FileClose($hOPN_AdobeFlash)
EndFunc

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

25 minutes ago, MikeC said:

Error:

"If" statement  has no matching "EndIf" statement

It seems you have something to work with using Subz' code. But to clarify, a single line If statement should not throw an error without an "EndIf". Did you try it exactly as written?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now