on Windows winlogon shell i specified to run a start.bat file which starts a program, now i want to run on windows logon specific programs for specific user.
for example, for user1 when windows starts it runs program1. for user2 when windows starts it runs program2. how can i do this ? if write on .bat how to know which user logined?
You can use the username variable: %USERNAME% for finding the name of the user currently logged in.
Modify the start.bat file, use if-else conditionals for running programs based on username.
Run start.bat at logon.
Related
So here's the case.
I'm in an a domain environment (Windows 7) where users are stripped from local administrator group. I created a batch file to install a program and it requires administrator privilege. After installation I want the program to be pinned to the current user start menu. The way I pinned it is by calling a powershell script from inside the batch file to do that.
So I can elevate the batch file to have admin privilege, but the problem is the program will not be pinned to the current user, and instead it is pinned for the admin user that I'm using to elevate the batch file. I'm guessing that this is because the powershell script was called from inside an elevated batch file, so it is also elevated.
Is there any way for me to achieve what I want without splitting the script?
I think that your problem is not about privileges or user.
You are probably editing the wrong environement to pin your program.
You should copy (or create) your shortcut in :
C:\Users\%USER%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
I am running few scripts in powershell and cmd through windows scheduler. I have to provide my credentials and access keys in both the cmd and powershell scripts.
Is there anyway where I can provide my credentials through parameters like in Continous integration Tools? or any other way?
ex:
SET Username=Usrnme
Set Password=pswd //shouldn't be visible
curl.exe --basic --u usrnme:pswd -X get "https:www.google.com" -k
I don't want everybody who has access to the system to view the username and password.
Please suggest.
Here are your options:
Put the user name and password in a file and read it into batch script variables using for /f command
If you not using "simple filesharing" (= home edition versions of windows) you can set security so only one specific user has access to a password file or leave it in batch script and make that file's security so only one specific user has access.
Any text you are passing on a curl command line it is visible to any process while your curl.exe process is running. Another task can list running tasks eg from command prompt wmic process where ^(name^="curl.exe"^) get commandline would show it. I don't know how to obscure that.
You can use the Powershell Credential Manager to safely store the password on local computer. Then you can add the parameter to the script that represents credential target. See the example here
I need to create a script to periodically delete files from a user's folder that contains files that have read only access to standard users. I have a script that works perfectly but it asks for authentication. I need it to run it unattended...
I'm not sure what process or command is giving you the authentication window (your question is not clear about that) but you can use do shell script for file handling without being asked for authentication.
do shell script "rm /path/to/file" password "<password>" with administrator privileges
Of course you need to have already administrator privileges.
I have recently acquired a windows 7 laptop from my late grandmother.
I have been using it for work and other things. I decided to create a VM using VirtualBox And now I want to create a user on the (Windows 7 Host) machine so that when I log into that user it autoruns a .bat script to start the VM. To make it clear I only want to run it only if the user "VM" logs in and not my normal user and it would be super awesome if it would autostart in full screen. I have a shortcut on my desktop that executes the command:
"C:\Program Files\Oracle\VirtualBox\VirtualBox.exe" --comment "VM" --startvm "12dada4d- 9cfd-4aa7-8353-20b4e455b3fa"
but how do I make an autorun.bat when I log into the User "VM"?
To run the batch file when the VM user logs in:
Drag the shortcut--the one that's currently on your desktop--(or the batch file itself) to Start - All Programs - Startup. Now when you login as that user, it will launch the batch file.
Another way to do the same thing is to save the shortcut or the batch file in %AppData%\Microsoft\Windows\Start Menu\Programs\Startup\.
As far as getting it to run full screen, it depends a bit what you mean. You can have it launch maximized by editing your batch file like this:
start "" /max "C:\Program Files\Oracle\VirtualBox\VirtualBox.exe" --comment "VM" --startvm "12dada4d-9cfd-4aa7-8353-20b4e455b3fa"
But if VirtualBox has a truly full-screen mode (where it hides even the taskbar), you'll have to look for a command-line parameter on VirtualBox.exe. I'm not familiar with that product.
I hit this question looking for how to run batch scripts during user logon on a standalone windows server (workgroup not in domain). I found the answer in using group policy.
gpedit.msc
user configuration->administrative templates->system->logon->run these programs at user logon
add batch scripts.
you can add them using cmd /k mybatchfile.cmd if you want the command window to stay (on desktop) after batch script have finished.
gpupdate - to update the group policy.
Just enable parsing of the autoexec.bat in the registry, using these instructions.
:: works only on windows vista and earlier
Run REGEDT32.EXE.
Modify the following value within HKEY_CURRENT_USER:
Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ParseAutoexec
1 = autoexec.bat is parsed
0 = autoexec.bat is not parsed
I've been experiencing a frustrating issue with Windows Run as Administrator. I have a program A which needs to be run as administrator. I also have a program B which is used to manage dependencies of other programs (mainly it creates Command Shells with the right environment variables). Now I don't have control over the B program, but for some reason it creates the Command Shell under a non-admin user even if I run it as admin. So when I start program A from the command shell, it fails because it doesn't run as admin. If I use the runas command to run it as admin, or if I set A's properties to always run as admin, when it starts it doesn't start in the environment created by B, so it doesn't get the PATH (and other environment vars). Does someone know if there is a way to use the runas command while preserving the current environment variables?
Have you tried the /env switch?
c:\>runas /?
[...]
/env to use current environment instead of user's.
[...]