I am creating a script function that will write info to a .csv file. There is no problem getting the script to work.
The only issue is with Windows Vista/Windows 7. I am trying to write to a csv into a sub directory of the Photoshop script directory. For Windows XP and Mac it works fine.
For Windows Vista (I would assume 7 as well) it will only work if Photoshop is running in administrator mode. I know that most users will not right click and select "Run as Administrator" to open Photoshop.
Windows Vista has a restriction about writing files to the Programs folder or any sub folders. What's worse, you don't even get an error to say it doesn't write. As far as the script knows, it writes to the .csv correctly. However, Windows has silently blocked the operation
Is there a way to over-ride the Windows Vista restriction in the script?
Thanks, Damon
Write to .csv in Windows Vista/Windows 7 in Programs folder
Write to .csv in Windows Vista/Windows 7 in Programs folder
This is one way of doing it.
Once run in administrator mode the newly created folder will have full access rights.
Code: Select all#target photoshop
main();
function main(){
var newFolder = Folder(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts")+"/myNewFolder");
var SCRIPTS_FOLDER = decodeURI(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));
var testFile = new File(SCRIPTS_FOLDER + "/SecurityTest.txt");
testFile.open("w");
testFile.close();
if(!testFile.exists){
alert("You must run Photoshop as Administrator to run this install script\rRight click on Photoshop and select Run as administrator");
return;
}
testFile.remove();
if(!newFolder.exists) newFolder.create();
if($.os.match(/windows/gi)){
var mybat =File(Folder.temp+"/folderperms.bat");
mybat.open("w");
mybat.writeln('echo Y|cacls "'+decodeURI(newFolder.fsName)+'" /t /c /g everyone:F');
mybat.close();
mybat.execute();
}
}
Once run in administrator mode the newly created folder will have full access rights.
Code: Select all#target photoshop
main();
function main(){
var newFolder = Folder(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts")+"/myNewFolder");
var SCRIPTS_FOLDER = decodeURI(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));
var testFile = new File(SCRIPTS_FOLDER + "/SecurityTest.txt");
testFile.open("w");
testFile.close();
if(!testFile.exists){
alert("You must run Photoshop as Administrator to run this install script\rRight click on Photoshop and select Run as administrator");
return;
}
testFile.remove();
if(!newFolder.exists) newFolder.create();
if($.os.match(/windows/gi)){
var mybat =File(Folder.temp+"/folderperms.bat");
mybat.open("w");
mybat.writeln('echo Y|cacls "'+decodeURI(newFolder.fsName)+'" /t /c /g everyone:F');
mybat.close();
mybat.execute();
}
}
Write to .csv in Windows Vista/Windows 7 in Programs folder
Thanks for the reply.
I'm actually using an install executable file to install the script. I am creating the .exe files from from an open source program called Install Jammer. Its actually a very powerful install creator.
What you suggested gave me an idea though. Maybe I could give the folder full access rights from the .exe itself.
I'm going to bring this up in the Install Jammer forum to see if this is possible.
I'm actually using an install executable file to install the script. I am creating the .exe files from from an open source program called Install Jammer. Its actually a very powerful install creator.
What you suggested gave me an idea though. Maybe I could give the folder full access rights from the .exe itself.
I'm going to bring this up in the Install Jammer forum to see if this is possible.