I want to put the following into a batch file so i can convert it to a .exe and allow another user to run it on another PC.
The user does not have local admin access and has a frequent problem with their com1 port. I have installed/copied devcon to the user's PC and have gotten this script working fine without the credential change, i just need to know how i can run the batch file as a local user.
This is what i have written:
runas.exe /profile /user:localpcname\administrator /password:12345678
Devcon disable "ACPI\PNP0501"
timeout /t 5
Devcon enable "ACPI\PNP0501"
"Runas" seems to always want to run something else instead of everything else in a batch file?
G'day Regejok, thank you very much that works perfectly. Yes i am aware of the security implications of an open text password in a batch file, and i am aware i could make the user a local administrator. However doing that would be a lot more difficult than this solution (GPO's manage local users and they are kept overseas) and i don't want to confuse the user(s) any more than i need to.
Add in the fact that the equipment attached to this one PC is flakey at the best of times has led me here.
I really like the fact that i can run additional commands within the same batch file by using the /c switch. I don't know much at all about scripting so this is a great help :)
It looks like the ampersands are used in a similar was as brackets are when writing/typing too: devcon do-this "blah"(and then do this)Devcon do-that "blah again"
I understand.
Related
I am trying to create a bat file that will run cmd as administrator, then execute net command as shown below:
runas /user:administrator cmd "net localgroup administrators mjordan /add"
The goal is to add whoever the current user is as a local administrator.
So the first part works like a charm, and asks for the admin password. Upon entering the admin PW however, I do not see said test user under the local admin group. My best guess is I made a syntax error. But oddly enough no errors show up and command-line exits as if it executed.
Also, how would I make this execute and add the current user to the local admin group (thinking in a %username% way)? Not sure I am using the proper terminology, but say the user logged on running this command is JSmith. How could I make it add without using his name so it works on any account rather than just JSmith
Do you guys notice any errors? ...I am fairly new to creating bat files, and am learning as much as I can, so i know i must have messed up somewhere. Also, any references or study help is appreciated! Thank you!
i'm trying to move file from 1 server to an other with schedule batch file, for that i use google drive as a third part where i store my files. i have made some script
#echo "executed %date:~-10,2%%date:~-7,2%%date:~-4,4%" >> Logs.txt
copy /y "C:\backup\Portal2%date:~-10,2%%date:~-7,2%%date:~-4,4%.bak" "c:\users\administrator\google drive\"
this script move a file from a directory to an other, it works fine if i click it,but if i try to schedule it doesn't work.
I tried to change path to a random path in my computer and scheduled it, it worked perfectly.
its like my computer doesn't recognize google drive at all.
When copying over a network you need to use credentials in the scheduled task that have access to the network resource.
This is probably a bit late for you but might be helpful to others who follow in your footsteps. I had this problem and it came down to security. When you run something in batch it doesn't have the correct permissions. I can't remember the exact solution but you need to set the batch task to run with your username.
I have multiple site on IIS.
I want to stop all of them with a batch file.
Raison : I have a program that create new site. But I got port conflict because on the creation the site try to start on the same port than another site. I can't tell my new site to not autoStart. The best way would be a little code for a batch file, that stop any website, without knowing their names. With that, at the end, my new site will be started and every other will be stopped.
maybe the Appcmd command could work (http://www.windowsnetworking.com/articles-tutorials/windows-server-2008/Configuring-IIS-7-command-line-Appcmdexe-Part1.html)
I dont know how to use the List and stop command (for each in List Stop). If somebody know how to do it in script? Or maybe there's another command.
I need to do it in batch file.
Iisreset /stop will stop all sites
This must sound too naive because I am not a programmer. I need help with a batch file execution.
There are two user accounts on my Windows XP enabled PC and one of these accounts is used by my brother. Sometimes I need to leave messages for him to read as a reminder of something, for example, to back up his personal folders when he logs in next time.
So, I created a simple batch file with the following code:
#echo off
msg * It's time to backup your folders!
When executed by double clicking, the file works fine and shows the expected message. I placed a copy of the batch file in "C:\Documents and Settings\Brother\Start Menu\Programs\Startup" but couldn't make it execute automatically when my brother logged in.
Could somebody please show me where I went wrong?
According to this answer on Superuser, the startup folders for XP are actually in
%AllUsersProfile%\Start Menu\Startup
%UserProfile%\Start Menu\Startup
So the Programs\Startup may be used for something else.
If you are using Windows 10, there are 2 things that may be doing this:
Your file needs Administrator privileges (When i copy any file to startup with Admin privileges it will not work). - My experience
When you boot your computer wait a bit (30 - 50 seconds) to load all files make sure to don't do anything.
This is my experience in Windows 10 please correct me if im wrong in anything
I tried searching relevant threads, it didn't worked. So here are the detailed question / situation, where I am looking for help.
I have 30 client nodes where I have setup SVN and checked out two folders (which needs to be updated) exactly when I want (forcefully).. e.g : "d:\gbv\textures" and "d:\gbv\characters"
then I put svnUpdate.bat file in main d: drive with relevant command e.g: "svn update blabla"
if I run this bat file by double clicking, it works fine ( it updates )
now I thought, I should create a batch file, where I type all 30 nodes IP, and set of commands, to run that batch file from local d: and it should work.
PROBLEM: I am unable to do this.
because I am unable to do this, from my cmd panel.
because I am not sure, how I can access network pc and tell it to run "d:\svnUpdate.bat" from its drive from dos prompt. ( obviously, I can do this via win explorer visually ).
Hopefully the question will make sense.
You can execute files on remote machines in a network using PsExec. I use it to execute batch files and pass parameters to them.
You'll probably need the -w option to set the working directory.
Of course this is a lot easier with powershell remoting, but since you already set it up with batch, PsExec works fine.