• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Conditionally Run & move the .bat file shortcut(i.e .lnk file) by vba macro

rottenrogue

New Member
Hi Guys,

I am looking for a macro that will play with .bat file(shortcut of that .bat file)
vba macro will be placed in macro.xlsm

I have a .bat file & i created a shortcut of that .bat file & we have to play with the shortcut of .bat file & that shortcut of .bat file is located at (when i clicked on properties i got target "C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\Files\Close Excel.bat" & start in C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\Files)


First Check shortcut of the .bat file is located or not & if it is located then move that shortcut of .bat file to C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle & run the .bat File
& If the .bat file is not located then do nothing

Thnx

I am looking for a vba macro

Code:
Public Declare PtrSafe Function ShellExecute _
    Lib "shell32.dll" _
    Alias "ShellExecuteA" ( _
    ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) _
As Long


Sub FFF()
Dim strFileName As String
Dim strFileExists As String
 
    strFileName = "C:\Users\WolfieeeStyle\Desktop\Close Excel.lnk"
    strFileExists = Dir(strFileName)
 
   If strFileExists = "" Then
   Set FSO = CreateObject("scripting.filesystemobject")
   FSO.MoveFile Source:="C:\Users\WolfieeeStyle\Desktop\Close Excel.lnk", Destination:="C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\"
    ShellExecute 0, "OPEN", "C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\Close Excel.lnk", "", "", 1
    Else
        
    End If
    
End Sub





By seraching on google & as per my condition i tried to modify the macro but i am not getting the correct macro
plz see, I think this macro needs a correction plz correct the macro & help me in solving this problem Sir
https://www.excelforum.com/excel-pr...ut-i-e-lnk-file-by-vba-macro.html#post5378034
 
I dont know much about vba & i have searched the same on google & i edited the code & i done the correction as per u (If strFileExists > "" Then )
now the macro is working & if anything else is there in the macro that has to be modified then plz let me know
Problem Solved
Thnx Alot Marc L Sir
& If any more changes is there in the macro then plz let me know Sir
Have a Awesome Day Sir
 
Yes, copying / pasting can't be obviously coding …

Means

plz let me know marc L Sir, If u have any suggestion regarding this macro,
I will change it if any more changes are required then
 
Back
Top