How to use directory names with spaces with shell?
I'm trying to use a directory with shell that has spaces in it.
I tried setting the directory path to a string but that didn't help. To use quotes in the Windows Command Line I heard you have to use \ (as it's already inside quotes).
Using "shell cmd blahblah\\"blah blah\"" won't work.
Any help or ideas would be greatly appreciated. Also if I'm not making sense please just say :)
Re: How to use directory names with spaces with shell?
vb Code:
Shell "explorer ""C:\Test Folder\"""
edit: i.e. replace " with ""
Re: How to use directory names with spaces with shell?
/that gives me a syntax error. This is currently what I'm trying:
Code:
Shell ("cmd.exe /k "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\""Session Manager"" /v blahblah /t REG_MULTI_SZ /d " + meh + file), vbNormalFocus
Re: How to use directory names with spaces with shell?
Shell ("cmd.exe /k ""HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager"" /v blahblah /t REG_MULTI_SZ /d " + meh + file), vbNormalFocus
Re: How to use directory names with spaces with shell?
Try using ShellExecute instead as its more powerful and doesnt have th space issue.
vb Code:
Option Explicit
Private Declare 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
Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2
Private Sub Command1_Click()
ShellExecute Me.hwnd, "Open", "cmd.exe", "/k HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager /v blahblah /t REG_MULTI_SZ /d " + meh + file, "C:\", SW_SHOWNORMAL
End Sub