Re: mkdir in wshshell.run
- From: Charles E Finkenbiner <CharlesEF_@xxxxxxxxxxxxxxxx>
- Date: Tue, 22 Jan 2008 08:29:59 -0600
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 messageOne reason I can think of to do it this was is related to the fact
news:db6c06b3-b557-45d6-ae6c-b49a1eb46565@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a script that is creating a whole directory structure that"mkdir" is a command that is internal to the Command Processor.
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
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.
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
.
- References:
- mkdir in wshshell.run
- From: sheel331
- Re: mkdir in wshshell.run
- From: Pegasus \(MVP\)
- Re: mkdir in wshshell.run
- From: Tom Lavedas
- Re: mkdir in wshshell.run
- From: sheel331
- mkdir in wshshell.run
- Prev by Date: Re: Object oriented
- Next by Date: Re: Object oriented
- Previous by thread: Re: mkdir in wshshell.run
- Next by thread: Re: list server connections with vbs
- Index(es):
Relevant Pages
|