How do i change the root folder that psexec.exe uses? - windows

Im trying to run a batch file on remote computer using psexec.exe
My code is;
psexec.exe \\192.168.13.187 -u Administrator -p default -d -i c:\temp\abc.bat
But when i execute this on command prompt, it connects to remote server's system32 folder then start the batch file.. Problem is that batch file has some CALL method in it (like CALL XXX.BAT) (XXX.BAT file is in the same folder.) Since psexec.exe uses system32 folder as root path, after running c:\temp\abc.bat file successfully, it could not CALL the other batch file. throwing 'could not find the file specified'..
My question is; how do i use the remote C:\temp\ folder as a root path after connecting the remote computer ?
Thanks for help in advance !!

Use the -w switch Luke.
-w directory Set the working directory of the process (relative to the remote computer).

Related

Batch script permissions issues

I have a batch script written to auto start and capture traffic on a server for me but for some reason when I run it wireshark tells me it doesn't have permission to the folder where the script is trying to save the file. I have tried multiple different folders on and off the server I have tried giving everyone including SYSTEM full access to the folder. I have tried remaking the folder. I have tried running under and not under admin credentials I have tried letting the system task run it. Always get a permissions issue.
The weirdest part is if I run wireshark manually and save the data manually it has no permissions issues. Just if I run the script is the problem. Although they're both run under the same admin account.
Here is the script in case you need to see the flags I used.
#echo off
cd C:\Program Files\Wireshark
Wireshark.exe -i 4 -k -a duration:10 -w C:\Temp
pause
I did try to use a powershell script I had found online but it was pretty old and I couldn't get it to actually run. So any recommendations are welcome that include powershell or batch
C:\Temp isn't a file; it's a folder. Try specifying an actual filename, like this:
#echo off
cd C:\Program Files\Wireshark
Wireshark.exe -i 4 -k -a duration:10 -w C:\Temp\foo.pcapng
pause

How to Specify PSEXEC file Copy path in remote System

I'am using the below PSEXEC switches to copy a file to remote system. By default it copies to C:\Windows. I have created a new folder C:\Suba, and the file needs to be copied to that path.
PsExec -f -c -d -u domain\username -p P#ssw0rd "\\10.XXX.XXX.XXX" "\\sharepath\list.exe" "C:\Suba"
This copies the list.exe from the share path to destination system to the path C:\Windows. But I need to be copied to C:\Suba
Thanks.

How to run batch file after file download (from Linux to Windows) throught FTP in Windows

I am doing file copy from Linux to Windows share through FTP.
Once copy is done I am moving it to isilon storage which is shared on network path (manually).
Now I have created a batch file, which will do copy from FTP shared path to network path.
So how can I start batch file after FTP download? How can I automate it completely?
from Linux
ftp -n ip
user "user" "pwd"
put app.tar.gz
Once it is done i want to move it network shared path
Just use the copy command in a batch file, after the ftp.exe finishes:
ftp.exe -s:download.txt
copy c:\dowloadtarget\myfile.txt \\server\share\target\myfile.txt
You can run the copy even from the FTP script (the download.txt), if you need it for some reason. Use the ! (escape to shell) command.
get /remote/path/myfile.txt c:\dowloadtarget\myfile.txt
! copy c:\dowloadtarget\myfile.txt \\server\share\target\myfile.txt
But why don't you download the file directly to the shared folder?
get /remote/path/myfile.txt \\server\share\target\myfile.txt

using mongodump to extract meteor data

I'll preface this by saying I have very little coding knowledge other than a few mongo tutorials so this may be a very simple answer, I'm trying to extract the data from my meteor project into a text file that can be edited.
Previously I've just had meteor (and Node.js) installed but I've installed MongoDB because without it my cmd window would tell me "'mongodump' is not recognized as an internal or external command, operable program or batch file"
I then followed the instructions here and confirmed that my host is at 127.0.0.1 with a port of 3001. At this point I also began running my meteor project and opened a new shell.
The project is running at D:/projectName and when I execute "mongodump -h 127.0.0.1 --port 3001 -d meteor" from there it still says "'mongodump' is not recognized as an internal or external command, operable program or batch file"
But if I execute the same line from the mongodump.exe directory (C:\Program Files\MongoDB\Server\3.2\bin) then it says "Failed: error dumping metadata: error creating directory for metadata file dump\meteor: mkdir dump: Access is denied"
The user you log in with doesn't have permissions to write to the
C:\Program Files\MongoDB\Server\3.2\bin
directory. mongodump wants to write to a directory beneath the current working one.
You can do two things. You can add the above path to your system executable path and then run mongodump from a directory you have write permissions on.
Or you can keep running it from the above directory but specify the --out option with a path to a directory you have write permissions on.
1- run cmd as an administrator
2- write in cmd : cd "C:\Program Files\MongoDB\Server\4.2\bin"
3- write in cmd mongodump
then it will work successfully

How to write command in windows batch file to copy a zip file from an FTP path to a local folder in my computer

I want to copy a zip file from an FTP path to a local folder in my computer.
My client previously used coreftp.exe for that purpose. But now he ask us to use ftp.exe [default in windows machine, available at C:\Windows\System32\ftp.exe] for that purpose. The ftp is in the format :
ftp://username#ftpserver.address.com
And want to download it to d:\sample\docs folder on my machine.
I want that in a batch file so that I can schedule it through windows task manager.
So could you please help me to write that command on the batch file.
Thanks a lot in advance.
FTP.EXE is capable of executing script files. So you could just put this into your bat file:
#ECHO OFF
CD d:\sample\docs
FTP -v -i -s:C:\some\path\ftpscript.txt
And something like this into your ftpscript.txt:
open ftp://ftpserver.address.com
username
password
cd myfolder
get some_zip_file.zip
disconnect
bye
This will download some_zip_file.zip into the current directory (d:\sample\docs).

Resources