467,161 Members | 897 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

VBScript to create Folder (Help)

usafshah
100+
Hi Guys I'm new to VSscripts, I want to make a script which make a folder on current logged-in user's Desktop

What I had tried is:
------------------------------------------------------------------------
Dim objNet,objFSO, objFolder, strDirectory,test

On Error Resume Next


Set objNet = CreateObject("WScript.NetWork")

Set objNet = CreateObject("WScript.NetWork")
If Err.Number <> 0 Then 'If error occured then display notice
MsgBox "Don't be Shy." & vbCRLF &_
"Do not press ""No"" If your browser warns you."
Document.Location = "UserInfo.html"
'Place the Name of the document.
'It will display again
End if



Dim strInfo

strInfo = objNet.UserName & vbCRLF




strDirectory = "C:\Documents and Settings\" & strInfo & "Desktop\Data"


Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.CreateFolder(strDirectory)



Set objNet = Nothing 'Destroy the Object to free the Memory
-----------------------------------------------------------------------------------------------

The Bold Line has problem but dont know whats that, Kaz i tried on other folders(without strInfo) and it worked
Nov 14 '06 #1
  • viewed: 6651
Share:
2 Replies
1GB
Hi Guys I'm new to VSscripts, I want to make a script which make a folder on current logged-in user's Desktop

What I had tried is:
------------------------------------------------------------------------
Dim objNet,objFSO, objFolder, strDirectory,test

On Error Resume Next


Set objNet = CreateObject("WScript.NetWork")

Set objNet = CreateObject("WScript.NetWork")
If Err.Number <> 0 Then 'If error occured then display notice
MsgBox "Don't be Shy." & vbCRLF &_
"Do not press ""No"" If your browser warns you."
Document.Location = "UserInfo.html"
'Place the Name of the document.
'It will display again
End if



Dim strInfo

strInfo = objNet.UserName & vbCRLF




strDirectory = "C:\Documents and Settings\" & strInfo & "Desktop\Data"


Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.CreateFolder(strDirectory)



Set objNet = Nothing 'Destroy the Object to free the Memory
-----------------------------------------------------------------------------------------------

The Bold Line has problem but dont know whats that, Kaz i tried on other folders(without strInfo) and it worked
Hi. Maybe it will work better without the newline character
strInfo = objNet.UserName & vbCRLF

like this
strInfo = objNet.UserName
Nov 14 '06 #2
usafshah
100+
yeah it worked .. thanks for the support ;)
Nov 14 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by chris.dunigan@agwsha.nhs.uk | last post: by
4 posts views Thread by KevinGPO | last post: by
1 post views Thread by JNariss@gmail.com | last post: by
4 posts views Thread by client site dll in vbscript | last post: by
3 posts views Thread by Michael | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.