I have created a basic .bat and a .vbs script in Windows 10. Now I want the script to automatically place itself in startup folder whenever it is opened for the first time. Any suggestions how to do it?
Related
I am planning to use batch file to run few commands in VMWare PowerCli tool. I am able to open Powercli tool by batch file. But after the tool is opened, it should automatically go to a specific folder and then run a file from that folder.
Eventually I would like this to add in Task scheduler so that it runs on specific time with no human interaction.
Is there a way to do it in batch or cmd? Any help is appreciated.
If I have read the question correctly you want to run a script on a VMWare VM using PowerCLI in which case you can use the invoke-vmscript command and set the scripttype to BAT
https://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/Invoke-VMScript.html
The batch file would change the location. Alternatively you can use the copy-vmguestfile command and copy the batch file over and just use the invoke-vmscript command to run that batch file.
If the eventual goal is to have start up run the file then use the copy command and use the invoke command to update registry keys regarding startup.
https://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.powercli.cmdletref.doc%2FCopy-VMGuestFile.html
There are bat files on some servers that we have. I have Winform app that can view directory files and executables on different server. Is there a way that (based on the selected bat file), to be be able to run that bat file on that server from the Winform app.
Not in the way you are thinking. If you run a batch file from your machine (via app or manually) it runs locally on your machine, not on the remote server.
If you can install software, PsExec maybe be a good fit. If not, I have a couple of options I can think of.
Alternatives: create an app that runs on the server that knows when to run the batch files (via messaging, database records, etc) or use the Windows Task Scheduler.
The Task Scheduler approach is fairly simple. You could have the batch files set to run every one minute and at the start of the batch file, you do a file check. Your WinForm would create that file and at the end of the batch (if the file existed at the start) it would delete the file that triggers the batch.
I am having trouble running batch files on Windows 7 that I created, and which run properly as Scheduled Tasks, on XP. When I run these batch files as Scheduled Tasks on Windows 7, the command window just closes quickly. The batch files actually consist of a wrapper that initiates another batch file that contains branching and call Python scripts - so it's a little complicated.
I'm comparing differences between my Windows 7 and XP machines. When I run these batch files on XP, the top bar in the command window says C:\WINDOWS\SYSTEM32\SVCHOST.EXE. I set up a simple batch file (that doesn't contain a wrapper, branching or Python scripts) on the Windows 7 computer and at the top it says taskeng.exe, please see capture below.
Does anyone have a suggestion on what I need to do to get the batch files running on Windows 7 as scheduled tasks? Maybe there's something missing from my Environment Variables? I have checked the paths and everything in my more complicated batch files that I transferred to Windows 7 - I should say I can get the batch files running when I actually navigate to folder containing batch files I created. I really need them to run as Scheduled Tasks. I'm not particularly savvy with batch files, but these were running really well for 1+ year on my XP computer. Thank you! Patty
On Windows 7 when creating a a Scheduled Task you can choose 'Start In' you can then change the location in which it is run (and the directory to file you are refering to within your batch file.) This is worth trying before checking other things.
Second I would check what permissions it is being run with on Task Scheduler, run it as administrator to rule this out.
I would also see what happens when you just double click on the batch file as a logged in user and go forward from that.
I have a .bat file that use xcopy to pickup users pst file from document and setting then copy it to a shared drive. users always for get to double click to run it. How can I add time and date for the .bat file to run on its own. Windows build schedule doesn't work at time. thank you!
Batch files can't run on their own. Something has to launch the batch file.
You can use Windows Scheduler to schedule the running of the batch file, and then test for the time when the batch file is run in the batch file itself. If it's not the right time, the batch file can just exit; if it is the right time, the batch file can do the backup.
Scheduled tasks can run at a specified time; I have one that runs every weekday (Monday through Friday) at 8:45 AM that runs a process to retrieve files via FTP.
If you need more information about using Windows Scheduled Tasks, you should ask a question about it at SuperUser; that subject is not programming-related and would be off-topic here.
No idea what you mean by Windows build schedule doesn't work at time and you don't say when you want this backup to run - hourly? Weekly? Once a day?
What you could do is investigate the use of the AT command - that may suit you. Perhaps install a batch to run AT in your startup directory.
Or perhaps it would be better to start a hidden batch from the startup directory and use the TIMEOUT or CHOICE command to make it loop periodically.
You would need to explain your requirement in more detail.
I want to create a Batch file that creates a folder automatically on logon with the date as the file name.
I want to create this folder every day to put my everyday stuff on it, so a folder with the date should be useful.
Write this command in a file mkdir %DATE% and save it as name.bat
And to make it run each time computer boots do this
Create a shortcut to the batch file.
Once the shortcut has been
created right-click the file and select Cut.
Click Start, Programs,
right-click the Startup folder and click Open
Once the Startup
folder has been opened click Edit and paste the shortcut into the
startup. Any shortcuts in the startup folder will automatically
start each time Windows starts.