I need to connect a lot of computers to a network printer, and I would like to send a simple batch file that do that instead of explain to each one how to use the windows wizard.
I searched on microsoft documentation and so far I can install a printer by using the printui.dll library, but only if I'm going through another computer, example:
I installed the printer through the wizard on a computer called PC1, and I set it in sharing mode, the name of the printer is PRINTER1
I can now run the command:
rundll32 printui.dll, PrintUIEntry /in /n\\PC1\PRINTER1
The problem is that in a configuration like that, if I delete the printer on PC1, every other computer will lose it too, and I can't figure out how to install the printer with his IP.
I would like something like that:
rundll32 printui.dll, PrintUIEntry /in /n 216.1.32.75 /m "Lexmark W812 (MS)" /b MY_PRINTER
When 216.1.32.75 is the printer ip, Lexmark W812(MS) is the driver needed and MY_PRINTER is the local alias of the printer.
All the computers are based on Windows 8.
Related
I have a Virtual Machine hosted elsewhere in the world.
What I want to do is to disconnect from this RDP session without:
Windows locking automatically
Screen resolution changing
I've solved the first issue of the windows locking by running this .bat file to end the session:
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)
However, when I run a script remotely to check the screen resolution, it drops down to 1614x834.
How can I explicitly set 1920x1080?
Try that:
Install software Remote desktop(I use "Ultraview") in your Virtual Machine
After running that command, remote to Virtual Machine with that installed software and then adjust the screen resolution to 1920x1080
Can exit the software when the configuration is complete, It does not affect the process
This worked for my project :3
My room mate and I have a homegroup set up, but that's all the networking we can do on the university network. Trying to copy one single file from his computer (in my docs folder, which i can access via explorer) to my computer.
xcopy /s /v /y "Homegroup\Aaron\DESKTOP-RHML0SE\Documents\Currency.bin" "C:\Users\Grant\AppData\Roaming\AnkhHeart\AnkhBotR2\Twitch\Databases\"
That's the code I have, and it doesn't seem to see the file on his drive (Homegroup\Aaron). I just get "File not found - Currency.bin. 0 files copied."
Copying from various places on my own computer works fine. How can i copy from his?
I came across a printer install script that is copied directly from Google. It installs the print driver every single time you install a new printer, which takes forever, and you have to be on the physical PC to use it.
I've tried something like the below, but get an error that my arguments are invalid.
rundll32 printui.dll,PrintUIEntry /ia /c\\PCName /m "HP Universal Printing PCL 6" /f "\\server\path\path\path\hpcu186u.inf"
I've also tried it with /K, /v, and /h in there to no avail. I can get it to run if I take out the /c and run it on the target PC, but even then I get an error about UNC paths not being supported.
I've also tried using prndrvr.vbs similarly but get an error 87 with that.
Any suggestions?
Partial answer
The fun with UNC parts should be easy:
Use pushd \\server\path to short time map a network drive to use it as a physical one. More info with pushd /?. To unmap the drive use popd.
However I am not sure in how far your script "did not work" with using the /c option as in your question. It might already have been sufficient to solve the UNC-path problem.
We're having an issue with our Mobile Broadband modem reconnecting after a drop. The issue has been elevated but a solution may take a while. A quick work around we found is disabling and re-enabling the device, however the security settings are such that our users can't enable/disable network adapters in Network Connections.
I created a batch file to handle the disable/enable but would like it to self-elevate for a non-Admin user. Even if I have to hardcode a local admin account into the file and convert it into an executable to hide the code. Here's what I have so far:
#echo off
echo Please wait while the Sprint modem is reset...
wmic path win32_networkadapter where name="Sierra Wireless Mobile Broadband Network Adapter" call disable
timeout /t 5 /nobreak
wmic path win32_networkadapter where name="Sierra Wireless Mobile Broadband Network Adapter" call enable
This works perfectly if I chose Run As: Admin. I really appreciate any and all help.
I've had a similar problem and solved it with the help of the windows task scheduler.
Create a new task within the scheduler which simply runs the bat file.
Select a an admin user as the acount to run the task with.
Enter the password (here is the big advantage - you don't need to store it in some script as plain text)
Create another bat file with the following content: schtasks /Run /TN <taskname>
Run the new bat file.
If this doesn't work, it might be because of the user nither has permission to run tasks. In this case you'll still have to store the credentials as plain text but
schtasks /Run /U <username> /P <password> /TN <taskname>
will do the trick.
I'm trying to open up a an .exe program that is on a remote computer through my main desktop using a batch file and psexec.exe.
I have been able to remotely kill programs using pskill, but when I run the command line required to open a program the window opens up for a fraction of a second before closing down due to an error. The error code it gives is: -2146232576.
I've tried Googling what this error actually is but I can't find much. Does anyone know for sure what this error relates to?
This is the batch file I made that does not work:
cd c:\Users\[local user]\Downloads\PSTools\
psexec.exe \\computername -u [user] -p [password] "C:\Users\[user]\Desktop\SQAUtilities\utlity.exe"
Note: I found a question on StackOverflow which is similar, but has a different error code:
psexec error code -1073740771
And also:
Error code 1073741502 when running psexec through TeamCity
This one has an answer that says the error is "a low-level .NET initialization error, the CLR cannot get loaded":
visual studio 2010: error code -2146232576 (0x80131700)
This is likely the exit code of utility.exe that PSExec is passing back to you, not an error generated by PSExec.
Here's one possible source:
FIX: 0x80131700 error code when starting or configuring the Enterprise Single Sign-On Service
I don't know what utility.exe does, but if it attempts to perform Windows authentication, PSExec might be blocking it. In my experience, PSExec deliberately blocks some actions (under certain circumstances). For example, if you don't use a username/password, all attempts to access remote shares fails instantly.
Since you're providing some creds, this might not be the precise problem, but if utility.exe requires access to your Kerberos tickets or something, they might not be accessible in a PSExec session.
Things to Try
Do you know that this command (utility.exe) works on the remote machines as your user when run interactively (GUI logon)? Surely you've already tried that, but just to make sure...
Is the build directory on the remote computer or is it a share on a third machine? The method of accessing those files might require more steps within PSExec (like mapping a drive, etc.).
If the program absolutely requires a GUI, you may have to allow it to interact with a specific GUI session using the -i parameter of PSExec. You might try logging into the remote machine, running the command with -i 2 (or whatever session qwinsta tells you you're using—2 is common for remote desktop connections) and see if it opens any error dialogs that are more informative.
You might try running ProcMon on the remote machine while you run the PSExec command and seeing if there are any ACCESS_DENIED or other failures that it notices.
Got the same error while remotely running an EXE install file (not copying it local). As near as I can tell this is an error related to insufficient permissions. For me, the simple addition of the -S switch (to run as SYSTEM) fixed my problem.
Why this works I'm not sure - I'd always thought SYSTEM was strictly limited to local resources, yet the EXE I'm running is located on a network share.
Hope this helps someone.
I got the same error lately and found out why I get this.
You must make a local copy of "utility.exe" on the remote computer for before launching it via PsExec.
for /f "usebackq delims=" %%i in ("d:\utility\remote_computers.txt") do (
xcopy "D:\utility\utility.exe" "\\%%i\d$\" && psexec \\%%i -u %%i\administrator -p password cmd /c "/i \\%%i\d$\utility.exe"
)
Pause