Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1364
  • Last Modified:

Create a folder on a remote computer (folder names consist of spaces)

This code INCORRECTLY creates a folder on the remote computer called "Program".
I actually want it to create a folder within Program Files called NEW FOLDER (C:\Program Files\NEW FOLDER).

msgbox "starting"
'strFolder = "c:\Program Files\NEW FOLDER"
'strFolder = "c:\Program Files\NEW" & chr(32) &  "FOLDER"
strFolder = "c:\Program" & chr(32) & "Files\NEW" & chr(32) &  "FOLDER"
msgbox strFolder
strComputer = "RemoteComputer"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
errReturn = objWMIService.Create("cmd.exe /c md " & strFolder & chr(34) , Null, Null, intProcessID)
msgbox errReturn
msgbox "Done"
0
goldstar
Asked:
goldstar
1 Solution
 
Shift-3Commented:
You just need another chr(34) in front of strFolder so that the entire path is enclosed in quotes.

msgbox "starting"
strFolder = "c:\Program Files\NEW FOLDER"
msgbox strFolder
strComputer = "RemoteComputer"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
errReturn = objWMIService.Create("cmd.exe /cmd " & chr(34) & strFolder & chr(34) , Null, Null, intProcessID)
msgbox errReturn
msgbox "Done"
0
 
goldstarAuthor Commented:
Big DUH but that is what I was hoping for.

Thank you for your quick response!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now