check is directory exist if not Create a folder
Updated: 21 May 2010 | 4 comments
Hi,
I am using wise 8.1 to create an exe file.
when I install the exe it deletes empty folder on the system. There is one folder which is need by the application for proper function.
I want to check the below:
if the folder exist than don't do anything.
else create a folder
the script i am using is not checking for it
Please find below the script:
item: Check if File/Dir Exists
Pathname=C:\Parag
Message=Directory Exist
Title=Check Dir
Flags=01000101
end
item: Else Statement
item: Create Directory
Pathname=C:|Parag
end
end
Thanks in advance
discussion Filed Under:
Comments
Try this VBS
sub CreateFolder(NewDir as string)
dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CreateFolder (NewDir)
set objFSO=nothing
endsub
http://www.linkedin.com/in/CaseyEdwards
VBscript
Here is the VBScript.
Set oFSO = CreateObject("Scripting.FileSystemObject")
If Not oFSO.FolderExists( "C:\Parag example") Then
Set objFolder = oFSO.CreateFolder("C:\Parag example")
End If
Thanks
Sid
Wise Script
Here is the wise script, you should not be using C:\ or D:\ directly in you your script. Instead you should Define variable using Set Variable and then assign C:\ or D:\ to the variabes and then use the variable in your script.
Following is the Wise Script that you can make use to create C:\Parag directory if it dosen't Exist.
-------------
Document Type: WSE
item: Global
Version=9.02
Flags=00000100
Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Copy Default=1
Japanese Font Name=MS Gothic
Japanese Font Size=9
Start Gradient=0 0 255
End Gradient=0 0 0
Windows Flags=00000100000000000010110000001010
Message Font=MS Sans Serif
Font Size=8
Pages Modified=00001000011000000000000000000000
Extra Pages=00000000000000000000000000010000
Disk Label=Default
Disk Filename=SETUP
Patch Flags=0000000000000001
Patch Threshold=85
Patch Memory=4000
MIF PDF Version=1.0
MIF SMS Version=2.0
FTP Cluster Size=20
Per-User Version ID=1
Dialogs Version=7
Crystal Format=10111100101100000010001001001001
Variable Name1=_INIT_WINDOW_
Variable Default1=HIDE
Variable Flags1=00001000
Variable Name2=_SYS_
Variable Default2=C:\WINDOWS\system32
Variable Flags2=00001000
Variable Name3=_WIN_
Variable Default3=C:\WINDOWS
Variable Flags3=00001000
Variable Name4=_WISE_
Variable Default4=C:\Program Files\Altiris\Wise Package Studio\WiseScript Editor
Variable Flags4=00001000
end
item: Set Variable
Variable=MYVAR
Value=C:\
end
item: Check if File/Dir Exists
Pathname=%MYVAR%\Parag
Flags=00000101
end
item: Create Directory
Pathname=%MYVAR%\Parag
end
item: End Block
end
--------------
Thanks
Sid
Create Folder
Hi,
Just try putting a create folder entry for that folder in the package. If the folder exists, it will not do anything, else it will create the folder.
This is just a try which you can do..
Piyush Nasa
Altiris Certified Professional (ACP)
Piyush Nasa Altiris Certified Professional (ACP)
http://msiworld.blogspot.com/
Would you like to reply?
Login or Register to post your comment.