copy command syntax error in Windows XP - windows-xp

Basically I am just trying to create a batch file to copy one file from one location to another location in Windows XP like the code below but failed. May I know why?
copy C:/Directory_A/the_file D:/Directory_B
When I execute the batch file I see this in the output:
The syntax of the command is incorrect.

Try using backslashes
copy C:\Directory_A\the_file D:\Directory_B

Related

WinSCP - Unknown command and '.log' is not recognized as an internal or external command

Context: I'm using powershell to instantiate a batch file to execute the synchronize remote command in WinSCP and pull in fresh data from a remote directory to my local directory. See screenshots below for contents of the WinSCP commands and the batch file contents.
When I try to execute I am able to successfully authenticate but I see 2 errors.
Batch file contents:
winscp.com /script=winscp_commands_ar_history.txt
/log=C:/Users/REDACTED/Desktop/AR_History_Report/winscp_log_ar_history.txt
WinSCP commands:
option batch abort
option confirm off
open sftp://REDACTED:REDACTED#sftp.REDACTED.com
-hostkey="ssh-rsa 2048 cc:ea:2e:03:96:ca:e7:c0:59:74:13:a8:XX:XX:XX:XX"
synchronize remote /export/GroupAccess/REDACTED/Cognos Reporting/CogTest
C:/Users/REDACTED/Desktop/AR_History_Report
exit
Powershell output:
Errors:
Unknown command '-hostkey=ssh-rsa 2048 cc:ea:2e:03:96:ca:e7:c0:59:74:13:a8:XX:XX:XX:XX'.
'/log' is not recognized as an internal or external command,
operable program or batch file.
Question: How do I resolve these 2 errors? I suspect the last one is related to environment variables since it seems powershell didn't recognize the WinSCP log command so I've added WinSCP to my PATH environment variable but I'm still getting the same errors. Can someone please assist? Thank you.
Both your batch file and WinSCP script have line breaks in the middle of commands. Moreover, in the synchronize command you need to wrap the path with spaces to double quotes.
The batch file should be:
winscp.com /script=winscp_commands_ar_history.txt /log=C:/Users/REDACTED/Desktop/AR_History_Report/winscp_log_ar_history.txt
And the script file should be:
option batch abort
option confirm off
open sftp://REDACTED:REDACTED#sftp.REDACTED.com -hostkey="ssh-rsa 2048 cc:ea:2e:03:96:ca:e7:c0:59:74:13:a8:XX:XX:XX:XX"
synchronize remote "/export/GroupAccess/REDACTED/Cognos Reporting/CogTest" C:/Users/REDACTED/Desktop/AR_History_Report
exit
As an aside, as #mklement0 commented, you don't need another powershell process to invoke a batch file from PowerShell - just invoke batch files directly: .\ar_trigger_history.bat

PostgreSQL copy 0?

I have written a simple batch script which loops a directory and echoes some details about each file.When I view its results in the CMD terminal or output it to some file, I can view the results as expected.
The problem comes with PostgreSQL: when I try to import its results into a table, executing the following command:
copy schema.table(field) from program 'C:\\...\\my_bat.bat' with CSV header delimiter E'\t';
It imports 0 results, whereas if I run the same command pointing to a similar batch file in another directory, it works as expected.
What's going on? I am using windows.
Update: I have tried running the copy command calling program again on another batch script and this time, only a part of the string output is being imported.
The service user postgres needs sufficient permissions to run the program.
I remember that it was hard to change settings for that account on windows XP, I have not tried on more recent windows - service users are hidden by most GUI tools.

PowerShell executing .bat files with in the same session

I am installing a software in silent mode using PowerShell. Installation was done successfully but when I am trying to execute few batch files I am getting some exceptions.
Could not find the files for the given pattern. The system can not find the specified path.
My command inside my PowerShell:
$inst_path = \\My installed drive (c:\program files\mysoftware\)
& $inst_path\start-service.bat install
But when I closed the PowerShell ISE and executing the same command it is working without any exceptions, so can someone help me overcome this?
You've got a double slash in the path to the bat file, both the $inst_path variable and the path you construct.
You're trying to call c:\program files\mysoftware\\start-service.bat - which is going to fail.
Try this instead:
$inst_path = "c:\program files\mysoftware"
& "$inst_path\start-service.bat" install

lost PATH while trying to set custom winlogon shell in WindowsXP

I have changed the shell key in windows registry to gain custom shell (Kiosk usage):
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon]
I set shell key to a batch file which runs two applications as below:
start "myFirstAppTitle" "myAppPath\myApp1.exe"
start "mySecondAppTitle" "myAppPath\myApp2.exe"
Each application runs but the second application which needs some files to be excuted throws an error which says could not find dependency files. whereas the dependency files are adjoining to the exe file and the mentioned app works fine, when starts from startup.
Meanwhile when i run the batch file manually it rusn fine.
I added the PATH command to the batch file but it did't work too.
Change the batch file to this:
set PATH=%PATH%;C:\MyAppPath
start "myFirstAppTitle" "myApp1.exe"
start "mySecondAppTitle" "myApp2.exe"
If you start executables without an absolute path, the path is relative to the current working directory. Also, when you specify an executable with a relative path, %PATH% is not searched for a matching subfolder with a matching executable.
Since the script worked when you manually started it, your working directory probably was C:\. However, when run at logon as a replacement shell, the working directory is most likely "%SystemRoot%\system32".
The problem solved strangely, i removed the title parameter of start command and it worked. In fact i used start command this fashion:
set PATH=%PATH%;C:\MyAppPath
start myapp.exe
start myapp2.exe

Command Line in Batch file?

I am making a batch file to automate mysql installation silently. When I type the following line in the command prompt everything works fine.
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqlinstanceconfig.exe" -i -q ServiceName="mydb" RootPassword="pos" ServerType=DEVELOPMENT DatabaseType=INNODB Port=3306
My question is: can I somehow add this to a batch file so it will run it as if I entered it in the command line?
Thanks,
Matt
yes, its easy. As Santa commented, just put your command inside some text file, change the extension of that file to .bat. Thats all !!