Get system directory path - autoit

I want to upload an image file using an AutoIt script:
WinWaitActive("Open")
Send("D:\sprint8execution\gGastro-mvn\tmp.png")
Send("{ENTER}")
How to give the system-defined path in the script so that if the script runs on any other machine it goes to applicable directory and fetches the image from there?

Have a look to the AutoIt macros. #ScriptDir is the directory that includes the current running script.

Related

pyspark: how to show current directory?

Hi I'm using pyspark interactively. I think I'm failing loading a LOCAL file correctly.
how do I check current directory, so that I can go to browser to take a look at that actual file?
Or is the default directory where pyspark is? Thanks
You can't load local file unless you have same file in all workers under same path. For example if you want to read data.csv file in spark, copy this file to all workers under same path(say /tmp/data.csv). Now you can use sc.textFile("file:///tmp/data.csv") to create RDD.
Current working directory is the folder from where you have started pyspark. You can start pyspark using ipython and run pwd command to check working directory.
[Set PYSPARK_DRIVER_PYTHON=/path/to/ipython in spark-env.sh to use ipython]
import os
cwd = os.getcwd()
print(cwd)

How can I pass arguments to a command that is run via psexec.exe?

I am running the following command format:
PsExec.exe -i -s \\\\ip -u username -p password "\\\\shared\driver\path\autoitscript.exe" "\\\\shared\driver\path\car.jpg"
The exe file takes in a file path and enters the path in a file upload window. The exe file is an AutoIt script (.au3 file converted). The script uses ControlSetText to enter the file path in the upload window. I can see the exe file being run on the remote machine, but for some reason the file path is not being entered. Is there something wrong in the way i execute the psexec command? Locally the script executes correctly.
I was using ControlSetText to send the file path into the upload window. That did not work. Instead use ControlSend or Send.

system command to open a file in r

need help to open a file in system directory like pdf file in
path ="c:\\abc\\xyz.pdf" with system default pdf viewer
Or to open image in folder using system default photo viewer
already try system('"E:\\pdf_ka_zakhera\\9780387981406-c1.pdf"') in R
Try this:
shell("E:\\pdf_ka_zakhera\\9780387981406-c1.pdf")
From "shell" help page:
To make use of Windows file associations, use shell.exec

AutoIt Script to run exe files

I created an AutoIt script to install my executable. But when I run it, nothing is executed. My script:
Run("agent.exe", "C:\temp")
After saving and compiling (using Ctrl + F7), nothing is executed. Why?
Try this:
Run("C:\temp\agent.exe")
Your code is telling it to run agent.exe in the current directory and telling agent.exe to use C:\temp as its working directory.
It is recommended to use absolute paths. Otherwise you may end up in a situations like this one.
By using just a filename "agent.exe" your script assumes that the file is in the current working directory. This is fine as far as the working dir doesn't change.
Use this For example:
Run (#ScriptDir & "\agent.exe", #HomeDrive & "\temp")

changing directory access using ICACLS.exe at runtime

I have the following syntax to change the directory access permission of the LOGO folder in the web application
ICACLS D:\Workspace\SampleProject\LOGO /grant "IIS_IUSRS":(OI)(CI)F.
This works fine if the application is deployed on local IIS, If the web application is hosted on some external server i am not sure what will be the exact path of the LOGO folder,that means cant hard code the path.
so i have written a console application , which gives me the complete path of logo folder on the server and the path is written to sample text file.
my question is their any way to substitute the path "D:\Workspace\SampleProject\LOGO" with the path obtained from text file at runtime ?.
As far as I understand from reading your question and comments, you have a text file with the path of the LOGO folder and you want to run icacls.exe from a batch file to set the folder permissions.
Say, your text file is named path_to_logo.txt and contains a single line with the path. Then the following batch script will do the job:
for /F %%l in (path_to_logo.txt) do ICACLS %%l /grant "IIS_IUSRS":(OI)(CI)F
for /f will loop through all lines in a file (and you have just one), assign the current line to a variable %l and execute what follows the do keyword.

Resources