By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,988 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,988 IT Pros & Developers. It's quick & easy.

VBScript to create Folder (Help)

usafshah
100+
P: 104
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
Share this Question
Share on Google+
2 Replies


100+
P: 1,646
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+
P: 104
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.