We have a file that we send to the bank and it worked via bat file when sending through FTPS.exe but not we must use PSFTP.exe which works for the desktop user but not the service account. We have tried logging in as the service account user and running the process which works when we are logged in as but not when scheduled through a Windows Server. Have also tried putting the Y in the bat file to answer the validate question whcih we have to answer only once when using desktop user without success.
I have read a lot of hits online pointing to authentication, using two files, etc... but not sure how to implement them. I would really appreciate assistance with this.
here is my bat file which is called by Gentran as an executeable, server is Windows 2008 R2, Service Pack1:
SET MOVEitIP=FTX-SERVSH.bnymellon.com
SET MOVEitUser=******
SET MOVEitPassword=******
echo cd /inbound/trp/ >> frommoveit.txt
echo mput D:\GENSRVNT\PositivePay\*.txt >> frommoveit.txt
echo quit >> frommoveit.txt
psftp -batch %MOVEitIP% -l %MOVEitUser% -pw %MOVEitPassword% -b frommoveit.txt
del frommoveit.txt
Basically took script from bat file for FTPS.exe and updated it for PSFTP.exe to use. Again, this works as desktop user and service account user (when signed into the server) but not when automated.
Thank you in advance for your assistance.
Krise
The service account must have the "Log On Locally" rights otherwise the account will not be able to logon to execute the sheduled task. I think you will see the logon error in the eventvwr at the time the task was run.
Related
I have a simple batch file which needs to be run weekly to upload some files via Core FTP.
I'm using the free version of Core FTP LE.
MySavedProfile is the Site Name of the saved profile I created using Core FTP's site Manager. The profile contains the URL / credentials / etc of the site to connect to.
Here are the contents of the batch file:
SET logf=confirm.log
echo test-start >> %logf%
"C:\Progra~1\CoreFTP\coreftp.exe" -B -s -pasv -O -site MySavedProfile -u "C:\Progra~2\PathToFiles\FileToUpload.txt"
echo test-finish >> %logf%
For the Windows Server 2012 r2 Task Scheduler, I have created a basic, weekly scheduled task on the Task Scheduler Library root which runs the batch file. For this scheduled task I have:
(Under the General tab)
"Run whether user is logged on or not" is selected
"Run with highest privileges" is checked
Configure for = Windows Server 2012 R2
(Under Actions)
Action = Start a program
Program / Script = "C:\Progra~2\PathToFiles\batch.bat"
Start in = C:\Progra~2\PathToFiles\
Here is the weird behavior I am getting:
If I double click on the batch file directly, it works fine and uploads the text file via Core FTP just fine.
However, if I try to let the Windows Task Scheduler run it, it runs everything except the Core FTP line. That is, I get the usual:
test-start
test-finish
in the confirm.log file, but the FileToUpload.txt has not been uploaded to the remote server, and there are no errors from CoreFTP that I can detect.
I have tried this with a service account that has permissions to run batch files, as well as my own account for this scheduled task. I get the same result: it doesn't seem to run that CoreFTP line. At least not via Task Scheduler. I need this upload to be automated.
I've searched Core FTP's documentation, Google, etc. No one seems to have run into this exact issue. I've applied recommendations from distantly related issues, but none of them have worked.
Any help would be greatly appreciated. Thank you.
The only way to do this is to use the full version of Core FTP (that is Core FTP Pro). If you use the LE version you have to check the "Run only when user is logged on" option.
This happens because of the splash screen at the beginning.
If you can't be logged on forever you could create a user that will always be logged on just for these tasks.
Remember to use the -Log option on CoreFTP to check if it is actually doing something.
I am in need of a script that will re-map a network drive. I will also need it to be able to enter admin credentials when prompted. The reason I need this script is that I don't want the user to know the password. Currently they have to call me and start a remote session so I can enter the password. This happens about every other day wasting time of both myself and my client. I have found a script that maps the drive (below) but lack the knowledge on how to have it enter the admin credentials.
#echo off
net use S: \Server\Sales
Thanks yall!
Open a command prompt window and enter net use /? to get help of this command or use the information provided by Microsoft on pages about
net use (best)
net use
net use
As you can read, a password as well as the user credentials can be appended also on the command line. I would have expected that an administrator knows all about that.
The batch file could contain:
#echo off
net use S: \\Server\Sales password /user:yourdomain.com\adminusername /persistent:no
But it is very unsecure to store the password and the user's / administrator's name in a batch file.
It would be definitely better to change the permissions on the shared folder so that those users who need access to this folder read-only or with write permission have access without mapping the shared folder using administrator credentials.
By the way: What is displayed in square brackets in help output is optional. This is a general rule for any Windows command on which help is output by running this command with /? as parameter.
I have built a windows batch file code that fetches the list of files from an FTP server and then pulls the appropriate file from that list. The batch file uses a combination of pscp.exe and psftp.exe in order to achieve this.
If I login as a member of the administrator group and execute this batch file manually (double clicking) it works perfectly, but the problem arises when I schedule a windows task to run that batch file from a windows service account (which is not in the administrator group).
The job when running under the windows service account is unable to execute the command for pscp.exe used in the code, whereas it executes everything else prior to that in the batch file perfectly normal.
Below is the line of code that I have used in my batch file :
pscp.exe -sftp -v -batch -pw %password% -ls %username%#ServerAddress:/outbox > F:\dirlist.txt
The service account is a member of BatchAccountsLG and ServiceAccountsLG groups, which is needed for the job to be able to execute the batch file code. Also, the service account has all the required access on any of the files/folders needed in the execution of the code.
I am not sure what the problem is because the batch file works perfectly fine if use my admin credentials, whereas it fails when the job is scheduled with the windows service account.
I have tried looking for an answer through google, but I have drawn a blank, any help on this would be highly appreciated. If there is anything else that I need to add to this, I would be more than glad to do so.
Thanks to all the ideas in advance.
I have a Server 2008 R2 Standard. I need to execute a batch-file using psexec from my PC Win7. The only time this worked is when i disabled the UAC on my server. Deactivating the UAC is out of the question, I'm looking for a solution with UAC enabled.
Error message:
Could not start PSEXESVC service on remotehost:
Access denied.
PS: In my command line of psexec I'm using the administrator user of my server to execute the batch-file. The UAC level is 3 on my server.
Best regards,
Tasso
It took me hours to find a working way to PsExec between two Windows 7 computers with a non-Admin user starting PsExec.
Disabling UAC...
EnableLUA=0
ConsentPromptBehaviorAdmin=0
LocalAccountTokenFilterPolicy=1
...did not work, turning off the firewall did not work.
Here I found the working way - thanks JelmerS (PSexec is not connecting to machine using supplied username and password).
*This is because psexec still tries to access the ADMIN$ share with your local credentials, before executing your command as another user. According to this thread, you can cache credentials before executing psexec:
cmdkey.exe /add:MACHINE_NAME_HERE /user:MACHINE_NAME_HERE\Administrator /pass:PASSWORD_HERE
psexec.exe \\MACHINE_NAME_HERE -i notepad
cmdkey.exe /delete:MACHINE_NAME_HERE*
Best regards, Peter
It seems that running PsExec from a Win7/Win2K8 machine against a Win7/Win2K8 target, regardless of the "-u" and "-p" params on the PsExec command-line,those params are ignored and PsExec is being executed remotely with whatever user credentials we happen to be logged in locally with.
Even though you stating which user account to execute the command on the remote system it executes the psexec command as the user that opened the command window.
When opening the Command Prompt, please right click it and select 'run as Administrator'. Meanwhile, make sure the user has administrator privileges on target PC.
The only solution i see to offer is to use the "Runas" (with the account you will need on the remote system) command to execute PsExec and forget the -u -p params.
In command prompt, you can try as,
echo "password" > pwd
runas /env /netonly /user:domain\Administrator "psexec.exe your_local_program.bat" < pwd
del pwd
Or just:
echo password | runas /env /netonly /user:domain\Administrator "psexec.exe your_local_program.bat"
Moreover....
Don't forget to check your Anti-virus which frequently blocks several of the PStools.
I'm trying to figure out how I can use a batch file to launch Internet Explorer as a local user on the system hosting the batch file. Ideally I'd like to be able to double click the batch file and not have to enter user credentials. To break it down a bit:
User is logged onto the host system with a domain user (Server 2008 R2 Standard 64bit)
User can then double click on a batch file that will launch Internet Explorer as a local user on the host system, without prompting for the local user credentials
All I can find is information about NET USE, any help would be greatly appreciated!
"runas" command was intentionally designed to prompt for password. So, that is not your solution.
One of option is to create a scheduled task where you can store the password (safely) and run the scheduled task from batch file.
But if the batch file is distributable and not going to be run on same machine.. you may have to investigate on how to create a schedule task from batch file and then run it.
you may find this reference helpful