Batch files executed from shortcut - windows

On Windows 7 Ultimate, I have a batch file that enables and turns on services related to vmWare workstation. Since the batch file is in the path, I can execute it from the command line in any directory, it works fine.
However when I try to run the batch file from the Windows Explorer (double click) or from a shortcut to the batch file it does not work; for example a typical SC command generates this error:
**
C:\Batch>sc config VMwareHostd start= demand [SC]
ChangeServiceConfig FAILED 5:
Access is denied.
**
Any ideas?
Thank you in advance.

Related

Run FORMAT command from task scheduler

I'm trying to get a scheduled Format running on Win10.
I have a Batch File that consists of the following line:
Format F: /V:test /Q /FS:NTFS /A:4096
Starting the Batch manually Formats the drive as desired, but starting the Batch as a Scheduled Task gives me an error:
cannot open volume for direct access.
I did a lot of Google Research but nobody seems to have found a solution or hasn't shared one.
I already did try/ensured the following things:
The Task runs with highest privileges
The user has admin rights and full Control over the Folder
I tried running it from SYSTEM - didn't work
The Task is configured for Win10 and running only as user is logged on

Windows Command Prompt Change

I'm trying to follow this tutorial and part of it involves working in the Windows Command Prompt. I'm running Windows 7 on a 64 bit machine and running cmd.exe as an administrator. The issue is this line:
../nw/nw.exe app.nw
The file/folder dependency is like this:
myNodeWebkitApps
helloWorld
nw
Where nw.exe is located in folder nw and I am executing the line of code from hellowWorld. app.nw is located in the helloWorld folder. The error I recieve is '..' is not recognized as an internal or external command. Any thoughts on how to execute this would be helpful.
Use ..\nw\nw.exe app.nw (inverted slash, which is the Windows standard path separator).

How to run batch file (As administrator) from Window Service

I have created a windows service, its running fine.
Now I would like to run a batch file as Administrator using windows service, because without administrator privileges it doesn't return any output.
So please let me know how can I do that. When I run directly using right click, run as administrator its working fine. Batch file as follows:
Runas.exe /noprofile /user:"Laxmilal Menaria" "lm.exe"
Thanks,
Laxmilal Menaria

Batch script to update hosts file on boot-up using curl

I am trying to get a .bat script to run on boot-up and purge the hosts file with a new one.
I have this working on Windows Server 2008 Standard X86 and it has been working consistently for over a year. I installed 'curl', hard linked it to System32 and schedule the following .bat script using local group policy:
curl x.x.x.x/latest/hosts > C:\Windows\System32\drivers\etc\hosts
Now I want to get the same script working on windows server 2008 R2. I have the same thing setup and it works if I double-click the .bat file. However, when the script runs on startup via GPO, it simply wipes the hosts file completely and I have to login manually and double-click the .bat script.
Any idea what's causing this?
Is it a difference between Server 2008 R2 and Server 2008 STD?
Try
curl.exe x.x.x.x/latest/hosts > C:\Windows\System32\drivers\etc\hosts.tmp
move C:\Windows\System32\drivers\etc\hosts.tmp C:\Windows\System32\drivers\etc\hosts

Running Batch File in background when windows boots up

How do I run a batch file each time windows boots up also I need to run it in the back ground(without that command window getting displayed)? I use Windows Xp.
My actuall requirement is I want to start the Tracd server using the command line commands whenever Windows boots up.
Add your program in the registry:
Run - These are the most common startup locations for programs to install auto start from. By default these keys are not executed in Safe mode. If you prefix the value of these keys with an asterisk, *, is will run in Safe Mode.
Registry Keys:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run registry key
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run registry key
Then you can launch your batch in an invisible mode:
wscript.exe "C:\yourpath\invis.vbs" "your_file.bat"
In invis.vbs put...
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
Two other startup posibilties:
you could always add the bat file to the startup folder,
or start it as a Scheduled task setting to run on logon.
You can make an application run as a service.
Check this article for details:
You can use autoexnt for this. It was original designed for windows NT, but is still working in newer versions of windows.
You have to download the Windows 2003 Resource Kit to get it.
There's also hstart, a third party program that's worked well for my needs. It's maintained too. The last version was released on July 7, 2010.

Resources