Re: mkdir in wshshell.run



sheel331@xxxxxxxxx wrote:
On Jan 21, 10:12 am, Tom Lavedas <tglba...@xxxxxxx> wrote:
On Jan 21, 9:34 am, "Pegasus \(MVP\)" <I....@xxxxxxxxxx> wrote:





<sheel...@xxxxxxxxx> wrote in message
news:db6c06b3-b557-45d6-ae6c-b49a1eb46565@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a script that is creating a whole directory structure that
doesn't exist, using the mkdir command. The script issues this simple
command:
backupdir = c:\migrations\backups\13833
relativepath = \sys3\sheel
wshshell.run mkdir & " " & backupdir & relativepath
when I echo out the command, it appears to build out the command
correctly, but when I go to execute it, it says "The system cannot
find the file specified"
Is it not finding the "mkdir" executable?
Thanks,
Sheel
"mkdir" is a command that is internal to the Command Processor.
To invoke it from another program such as cscript, you must
launch it through the command processor like so:
cmd /c mkdir
I wonder why you would want to create a folder in this way.
Doing it directly from a batch file would be simpler, or using
the VB Script function
objFSO.CreateFolder(FolderName)
would be much cleaner than the hybrid you currently have.
One reason I can think of to do it this was is related to the fact
that mkdir (md) can create multiple folder levels with one pass. The
logic required in a script is significantly more complicated.

For example, this script can be installed for doing this from the
Right-click menu ...

with createobject("scripting.filesystemobject")
if Wscript.Arguments.Count = 0 Then
sPath = .GetFolder(".").Path
Else
sPath = Wscript.Arguments.Item(0)
End if
sNewName = inputbox("New Folder Name:", "Create Folder")
for each name in Split(sNewname, "\")
sPath = sPath & "\" & name
if Not .FolderExists(sPath) Then .CreateFolder(sPath)
next
createobject("WScript.Shell").Run "explorer " & sPath
end with

The Right-click menu is accomplished with the following registry
entry ...

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\NewFolder\command]
@="wscript.exe \"C:\\Documents and Settings\\%username%\\My Documents\
\Scripts\\NewFolder.vbs\" \"%1\""

Note that the default value after the @= needs to be all on one line.
Also, the location of the NewFolder.vbs script is arbitrary, but needs
to be reflected in the registry entry.

I actually use a much more complicated version of this that performs a
self-registration on first execution, displays a character
representation of the folder tree and supports multiple tree branches
in a single invocation of the procedure. I'll see if I can get it
posted on my web site today, in case anyone would care to have a look.

Tom Lavedas
===========http://members.cox.net/tglbatch/wsh/- Hide quoted text -

- Show quoted text -

Tom,

You hit the nail right on the head. The reason I'm using that is
because I am creating multiple levels, not just the last level.

Thanks for your help!

Sheel

Hi,

If you want a VBScript solution then this is the code I use:

sPath = "r:\xxx\yyy\zzz\" ' Trailing \ is required
iPos = InStr(4, sPath, "\", 0) ' Skip drive letter check
Set oFSO = CreateObject("Scripting.FileSystemObject")
While(iPos <> 0)
If(Not(oFSO.FolderExists(Left(sPath, iPos)))) Then
oFSO.CreateFolder(Left(sPath, iPos))
End If
iPos = InStr(iPos+1, sPath, "\", 0)
Wend
Set oFSO = Nothing


Hope this helps,

CEF
.



Relevant Pages

  • Re: Modify Registry on all SBS2003 clients
    ... registry setting to all workstations. ... command "REG ADD" to modify registry. ... the following command will change the registry value as your ... You may copy above command into the login script file SBS_LOGIN_SCRIPT.bat ...
    (microsoft.public.windows.server.sbs)
  • Re: Mapping drives and adding to the path
    ... Please be absolutely certain that the PATH registry key stay as ... You will need to run with the elevated privileges of the Group Policy login ... script instead of the logged-on user to make these modifications. ... Perhaps you can use the REG command to manipulate this key (belive this ...
    (microsoft.public.windows.server.scripting)
  • Re: Modify Registry on all SBS2003 clients
    ... registry setting to all workstations. ... command "REG ADD" to modify registry. ... the following command will change the registry value as ... and put the command lines at the bottom of the script file. ...
    (microsoft.public.windows.server.sbs)
  • Re: mkdir in wshshell.run
    ... doesn't exist, using the mkdir command. ... The script issues this simple ... correctly, but when I go to execute it, it says "The system cannot ... "mkdir" is a command that is internal to the Command Processor. ...
    (microsoft.public.scripting.vbscript)
  • Re: Expected Statement error
    ... or something from a command line 'For' loop (my DOS knowledge is ... The OP is trying to alter the registry to create a file ... approach manually and the registry hack in a script. ... script, i have a .REG file that i know works on the PC's, maybe this ...
    (microsoft.public.scripting.vbscript)