views:

36

answers:

1

i did the following vbscript code to write a text file called "level.txt" in C:\Documents and Settings\All Users\Application Data\secon\generator

Const CommonAppData = &H23&  
Const PATH = "\secon\generator"
Dim fso, MyFile
Set objShell  = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(CommonAppData)

Set objFolderItem = objFolder.Self
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(objFolderItem.Path & PATH & "\level.txt", True)
MyFile.Close

this is working fine in XP,but windows2008 server machine its not creating any body has idea how to do this.How can i implement "SHGetFolderPath" for "CSIDL"

A: 

On Windows Server 2008, the location of AppData is normally c:\ProgramData. Try creating the c:\ProgramData\Secon\Generator folder first, and your script should run.

Also, try running the script using an administrator account, or changing the permissions of the generator folder to allow the user running the script to write to the directory if you still have problems

Duke Spukem

related questions