Basic bat file to net use network drives isn't working.
I can UNC to \server\netlogon and run the script and it works fine.
Manually changed the script to output text and pause to test if it was actually working and failing for some reason but nothing happened. I can UNC to \server\netlogon and run the script and it works fine.
Related
I need to map a network drive as a the local system account on a server, I can achieve this fine by running psexec -I -s cmd.exe then the net use command
My issue is the drive disconnects on reboot, even with persistent set to /p:yes
I’ve been trying to create a batch file that will run at startup that will run cmd via psexec, and then execute the net use command.
I can get to this point where cmd runs but I can’t get the next part of the command for net use to appear in the new cmd window.
Has anyone got any ideas/a better way of doing this altogether?
As a side note, the network share requires separate credentials to connect to it so it has to be mapped in such a way that credentials can be specified.
Have you tried saving the file as a .cmd file type and placing it in the shell:startup folder? It will run automatically every time you log in to the pc.
On my Windows Server 2008 R2 machine, a batch file is scheduled to run using Task Scheduler. For some reason, only a portion of the commands in the batch file are executed; Some commands are ignored.
Batch file looks like this:
cd s:
cd "S:\Reports\"
sqlcmd -S ipAddress -U login -P password -d dbname -i "S:\query.sql" -o "S:\Folder\Report.txt"
copy /A /Y "S:\Folder\Report.txt" Y:\
When I run the batch file by double-clicking on it, everything runs as intended; But when it is executed from task scheduler, only the sqlcmd portion runs correctly. The copy command does not seem to run. Even when I replace copy command with xcopy or mkdir or any other command, it does not run.
Even if I change the order of commands in the batch file, the commands do not run. But when the batch file is executed by double-clicking, everything runs perfectly.
The Y:\ is a mapped drive under the same login. After typing my question this far, I went back and ran one more test. Interestingly, if I replace mapped drive with local drive, everything seems to be working okay. So, at this point it looks like mapped drive is the problem. Any ideas on resolving this?
Essentially, how to copy or move files to a mapped drive (different machine) using batch file executed from Task Scheduler?
S: and Y: are probably mapped network drives, but those are mapped in the context of a user session. The scheduled task will be run in its own session and won't have those drives mapped.
You should use the UNC path of the share instead (\\server\share) as that should work in either context (as long as the share is accessible to the user the scheduled task is running as).
this is what I need to achieve is to update data on a server from a users machine. I have used net use and that part works, but trying to run the program doesn't. Here is my batch file:
#echo off
net use \\servername /user:admin admin <- This works and logs in "command completed successfully
"C:\program files\demo\dm.exe" /r "D:\demo\demoDeploy\roll\dem_dem_Extract.dmv" <-this however gives error message:
The system cannot find the path specified.
any help will be appreciated
I have a simple batch file that uses Robocopy to transfer data from one of our servers to a NAS device. I have tried using both a mapped drive as well as a UNC path.
It works when I run the batch file manually (using both mapped drive and UNC) but when I use Scheduled Tasks the command window does not come up and although the task is shown as Running it just sits there and does absolutely nothing at all.
I have set up the scheduled task from the Administrator account, have "Run whether user is logged in or not" with the admin password stored.
Is also set with Run with highest privileges and under actions I have set "Start in" to the root of the D:\ drive which is where the batch file is located.
I have also checked local security policy & everything seems fine in there.
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.