AppleScript to move folder contents to another computer - applescript

I have never written AppleScript in my life (a few Powershell and batch files for work, but I am by no means an expert on those even). I've used automator before to do similar things, but the program I need to have run the command only accepts AppleScript.
I need an apple script that can do the following
Mount an network share (windows machine network share, if that
matters, username and password are stored in Keychain)
Move (NOT copy) all the contents from a folder on my MacBook to that share
Unmount that share.
Alternatively, I have this already in a workflow, so if there is a way to convert/export/whatever a workflow into an AppleScript, that would be awesome too!
Any help would be greatly appreciated!

Related

Associate Shell Script to file extension

This may be a toughy or straight forward enough but trying to run a shell script every time a file is open to stop people accessing in use files. The file is in fused from a Google Cloud Storage bucket to a Ubuntu VM with a copy living in another bucket. When a user opens a file I want to run a shell script that sets the copy to read only. Anyone know a way or potential avenue I could explore to achieve this?
Thanks in advance

Visual Basic 6. Global/Public Folder Location That Limited User Can Write Data

I am a vb6 coder, and facing problem with a Windows 7 UAC issue.
Limited User:
When I run my installer, it asks for an admin account password, I enter and it installed it correctly.
My app writes dates to a common application data folder so that all users can access the file/data.
In Windows 7, the path is :
C:\ProgramData\<CompanyName>\<AppName/Title>\Config.ini
as my installer runs with admin rights, it creates those subfolders correctly.
But, when the app runs from a limited user account. It failed to write at that location (it actually writes to virtual path).
But, I want to write to that exact file.
However, I have researched enough and every where it is told to write in CommonAppData folder.
But it still fails.
please some one help me out.
I use SHGetSpecialFolderLocation API call to get the folder location and I use folder id 35.
below is the sample code for the path:
strAPPPath = fGetSpecialfolder(35) & "\" & App.CompanyName & "\" & Trim(App.Title)
I wasn't trying to suggest that your installer was the problem, I wanted to know what capabilities that your installer had. As I said I am running a post install Custom Action, in it I make my directory, set the permissions on it and copy my config files to it. It looks like your Installer has the ability to do Interactive and Shell Operations, but since I am not familiar with it I will refrain trying to give you an example. The command that I use to set the permissions of the Directory is the dos calcs command. And the command line that I use is.
cacls "%ALLUSERSPROFILE%\**<Your Directorys here>**" /E /P BUILTIN\Users:F
I was hoping someone would jump in and give an alternative way to do this, since I would like to loose the bat file.
You could try using procmon from www.sysinternals.com (which redirects to MS Technet) and find the disk access that your application is making to access the data folder.
It will give you a better error message that should point you in the right direction, such as permissions.

Automatically creating shortcuts on any Windows computer

I'd like to create some sort of script that will create a particular shortcut on the desktop of any Windows computer. The idea is to make the script available (to students in a course) so that they can download it to their computer and run it just by clicking it (i.e. not running it at the command-line). The script will have to check for some particular folders and files, and, if they exist, create the shortcut.
I'm a Linux guy and know very little about Windows, and so I am not even sure where to start to looking. I considered into using a Python script to do this, but that apparently requires installing some Windows-specific extensions, which I don't want to insist that that users do.
This can be done in VBScript, using the Windows Script Host which should be installed and usable on nearly any recent enough copy of Windows.
You want the CreateShortcut() method of the WshShell object which gets you an object representing a shortcut. You'd modify its properties and use its Save() method to actually create the shortcut file.
I've linked to the scripting guide at MSTN, as well as a page specific to the shell object. That should be a good starting point.
For this, I often work up a quick NSIS script and compile it to an EXE. The result is a very small executable. You can download NSIS itself at http://nsis.sourceforge.net/Download. I recommend HM NIS Edit to start with, as it has a wizard that builds a base script for you. Most of that wizard won't be applicable to your situation, but it is a good way to get started. Notepad++ also does syntax highlighting for NSIS.

Creating drives to remote resources in windows?

There does not appear to be any good software to mount an FTP to a local drive letter (see here for details SF Question) so I was thinking why not just write it myself, but I have very little experience dealing with windows (at the programming level) so what would be involved in doing something like this? What needs to be done to get a new "drive" listed under "My Computer"? What needs to be done to then get the contents of the FTP (or other remote resource) listed that "drive"?
My initial thought would be you would need to write a shell extension to be able to show your FTP site, and that it would best be shown as a special folder in Windows Explorer. Your extension would ideally be written in a non-managed language that supported COM (C++, VB 6, etc). It would need to respond to events like:
The user highlighting a folder on the server
The user double-clicking on a folder on the server
The user dragging and dropping files to and from the server
The user wanting to disconnect/reconnect from the server
When you intercept these events you would issue the appropriate FTP command to accomplish the task (use LIST to get the contents of a directory, MKD to create a directory, STOR to upload a file, etc). You would have to take the results of these commands and show them in the folders view and the listview within Windows Explorer, and for that you will likely need to get up close and personal with the Win32 API. For that you can turn to books like Charles Petzold's classic Programming Windows. Also check out this tutorial on writing shell extensions.
It sounds like an interesting project.

Why can I write to a particular directory off of Program Files with UAC on?

This is a strange one to me. Let me list the setup:
Application with a manifest (ie: wont get pushed to virtual store)
UAC is turned on (can't write to other program files directories, or other areas, and uac prompt appears)
Can write to "c:\program files\%app_name%\%directory%\" both from within my application (not run as admin) as well as a non admin command prompt
Can not write to "c:\program files\%app_name%\%directory%\%subdirectory%\".
Any ideas? Are there hidden permissions or registry settings somewhere? Could it be that this directory was created when UAC was off, so now its fair game? Could it be that this directory was created in a time of XP, and its fair game?
It makes sense to me why i can't write to the other program files directories and the subdirectory. However I have no idea why i am actually allowed to write to the %directory%?
Side note: If I move the %directory% to another area (appdata), I still can not write to the subdirectory (confused).
Let me know any ideas you may have or anything I can check.
Thanks
EDIT: Arr, sorry, I skimmed your post a little too fast, looks like this is a non-issue!
Have you looked where the written files are actually going?
Vista has a feature where files written into Program Files folders by applications get redirected to a local per user store. This store is located at %userprofile%\AppData\Local\VirtualStore
This is to allow legacy applications which wrote per user settings to Program Files to still operate correctly, also allowing multiple users to use the program without conflict.
There's a button in explorer called 'Compatibility Files' which will take you to this user store.. perhaps your writes are ending up there?
I'm not sure why you cant write to the subdirectory though. Security permissions?

Resources