Batch programming DOS pSEXEC

I have a batch file, say A.bat. When doing this A.bat will create another batch file, say remote.bat

If I manually copy remote.bat to a remote computer, then it works 100% perfectly. However, if I use it as part of psExec in my A.bat, then it does not work at all. However, my A.bat at runtime says.

Connecting to ABCDEF machine
Starting PsExec Server on ABCDEF machine
Copying C:\remote.bat on ABCDEF machine
Started C:\remote.bat ABCDEF machine with Process Id XXXX

However, it seems to me that the remote.bat file is not running at all.

What do I have inside remote.bat ..

net use \\DIR1\DIR2 password /user:Administrator 
XCOPY \\DIR1\DIR2\DIR3\DIR4\* c:\DIR3\DIR4\ /E 

I do not see the creation of DIR3 \ DIR4 created in C: of my remote machine at all. However, it works if I manually copy the remote.bat file and run it on the remote computer.

The command I use to call PsExec is

psexec \\MachineName -u Administrator -p pasword -d -c -f c:\remote.bat

Any tips? you are welcome?

+3
source share
1

BAT CMD . , Shell , psexec cmd .

cmd.exe /c remote.bat :

psexec \\MachineName -u Administrator -p pasword -d -c -f cmd.exe /c c:\remote.bat

remote.bat. :

net use \\MachineName\C$ password /user:Administrator 
XCOPY remote.bat \\MachineName\C$\remote.bat
psexec \\MachineName -u Administrator -p pasword -d -c -f cmd.exe /c c:\remote.bat
net use /delete \\MachineName\C$
+2

All Articles