0

I currently have the following code to call a vbs file that is in a folder within Program Files. It was originally in a different location (within the same folder) and it would work, but now there is a padlock symbol next to the folder within Program Files, and after changing the location (VBA updated for this as well), it won't call the file. I'm wondering why this is happening.

Sub ChangeThemeBasic()

Dim filespe As String
filespe = "cmd.exe /c C:\Program Files\Theme Changer\ChangeTheme.vbs"
X = Shell(filespe, 1)

End Sub

EDIT:

This works for some reason, I don't know why though:

Sub Test()
Shell "Explorer.exe ""C:\Program Files\Theme Changer\ChangeTheme.vbs""",1
End Sub
6
  • 2
    what OS version? you may need elevated privileges to access Program Files Commented Aug 12, 2014 at 14:40
  • Windows 7 Professional SP1 Commented Aug 12, 2014 at 14:41
  • Well I am sending this code out to some friends as well, and I have a batch file that moves the folder to program files so it is easily accessible. I need to make sure VBA can run the files in it on anyone's computer. I can go into the folder and click the file and it does what I want it to do. But it doesn't seem to read from VBa :/ Commented Aug 12, 2014 at 14:42
  • what about using the appdata directory? Environ("AppData") to get the location. Commented Aug 12, 2014 at 14:49
  • You mean place the folder in AppData instead? Commented Aug 12, 2014 at 14:51

1 Answer 1

1

From comments

Sub ChangeThemeBasic()

Dim filespe As String
filespe = "cmd.exe /c " & Environ("AppData") & "\Theme Changer\ChangeTheme.vbs"
X = Shell(filespe, 1)

End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.