AppleScript: how to eject/unmount NAS? - applescript

I'm trying to eject/unmount a mounted NAS.
It has been mounted with:
set serverName to "MyNAS"
tell application "Finder" to open location ("afp://" & theUser & ":" & thePass & "#" & serverName)
I tried:
tell application "Finder" to do shell script "diskutil umount \"" & serverName & "\"" --***
tell application "Finder" to eject serverName
But it returns a -10010 error: appleEvent can't handle objets of this class.
Thank you for your help.

Why do you use always the Finder?
open location and do shell script are part of Standard Additions, they are none of the Finder's business.
set serverName to "MyNAS"
open location ("afp://" & theUser & ":" & thePass & "#" & serverName)
and
do shell script "diskutil umount \"" & serverName & "\"" --***
The error occurs because you are trying to eject a literal string rather then the diskserverName
Usually you are mounting a disk of a server
open location ("afp://" & theUser & ":" & thePass & "#serverName.local/volumeName")
and you are ejecting the volume, not the server
tell application "Finder" to eject disk "volumeName"

Related

UFT is getting killed while opening database connection

Running the below line result with killing UFT while executing:
gdb_Conn.Open "Driver={Microsoft ODBC for Oracle};Server=" & & ";Uid=" & ";Pwd=" & & ";"
How can I solve it?
What is the error message you get?
I expect that there are variables between the two & & and there's missing & after the uid? So it looks like this?
gdb_Conn.Open "Driver={Microsoft ODBC for Oracle};Server=" & server & ";Uid=" & uid & ";Pwd=" & password & ";"
If not you need to complete the line with the variables holding correct values (server name, user and password pair that has access to it).
Otherwise check that the server is running, you can connect to it manually, the user has access etc.

pscp upload using vbs

I am attempting to create a function in VBScript that uploads a text file to a remote server using the pscp command. When I run the function, I receive the error
80070002 - The system cannot find the file specified.
Below is the function, I was wondering if there was an issue with the pscp command or if there was an alternative way to upload a file in VBScript.
Function upload(source, dest)
WScript.Echo source
Set system = WScript.CreateObject("WScript.Shell")
system.Run "pscp -batch -pw [PASSWORD HERE] " & source & " [USERNAME HERE]:" & dest, 0, True
WScript.Echo "....Finished " & vbCrlf
End Function

sudo an application asking the user with a dialog?

I'd like to run an OSX application with admin privileges, so the user would be asked first for his admin log/pass.
Is there a bash command or an applescript command that would allow me to do that ?
Sort of a sudo command but with a graphic dialog shown to the user, similar to what the Finder shows when asking permission to write files in restricted folders.
thanks !
(if by OSX application are you talking about the applescript one?)
In applescript, you can display a dialog that finder displays for the users login and password but this will not tell you the password, it will basically run a shell script as sudo:
do shell script "myadminshellcommand arguments" with administrator privileges
By adding "with administrator privileges" you are telling AppleScript to run a shell script in sudo with the users password
(Don't add sudo to the command)
to carry an application on any Mac, you have to ask for password
tell application "System Events"
set fullname to full name of current user
end tell
display dialog fullname & " Enter your password " default answer "" with hidden answer
set the adminpass to the text returned of the result
set PW to result
do shell script "echo " & quoted form of (fullname & " " & PW) user name fullname password PW with administrator privileges
tell application "System Events"
set TheUse to ("/Users/" & name of current user & "/Desktop/")
end tell

Issue while executing a vb script upon machine startup

I have a vbscript that adds a user to the local group "Administrators" which should run upon machine startup.
the basic code applied in the script is as follows:
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ",group")
' Get user object
Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user")
' Add user to group
objGroup.Add(objUser.ADsPath)
Now I added a registry string to the following path:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Name : addUser
Value : "E:\addUser.vbs"
Now the peculiar behavior which I have noticed is that when a non-admin user logs in the script doesn't run. It only runs for members of Administrators group.
If this behavior is expected, then is there a way to by pass this (maybe run it under the Administrator or SYSTEM account).
Thanks and Regards,
Wriju

vbscript , creating a new directory using mkdir doesn't work [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I am having problem creating a new directory inside my FTP using mkdir,
here is the code
script = script & "open " & hostname & " " & port & vbCRLF
script = script & "user " & username & vbCRLF
script = script & password & vbCRLF
'script = script & "lcd " & """" & localDir & """" & vbCRLF
script = script & "mkdir" & variableName & vbCRLF
script = script & "binary" & vbCRLF
script = script & "prompt n" & vbCRLF
script = script & "put " & """" & strline & """" & vbCRLF
instead of creating a new directory 'fff' and putting file there, it is putting all the files in parent directory.
What am i doing wrong ?
You are missing a space after mkdir.

Resources