EC2 Windows Instance not starting batch file from startup folder after restart - windows

I am trying to configure an EC2 Windows 2008 server instance to automatically start a batch file after the instance is restarted (to connect to Jenkins). I have placed a shortcut to the batch file in the Startup folder in the Windows menu.
The problem I am seeing is that the instance does not start the batch file until I actually login to the instance with remote desktop. As soon as I log in to the instance, the file is executed.
How do I make sure that the batch file is started as soon as the operative system is loaded?

I figured it out. The trick was to automatically log in after the instance is restarted:
Open the Start Menu, type netplwiz in the search box, and press Enter.
Untick Users must enter a user name and password to use this computer
Enter the windows password in the confirmation dialogue
The instance will now run the items in the Startup folder in Windows.
If this is not configured on the instance, the login will actually happen when you remote desktop into the instance.

Related

VBScript is not working on remote-desktop when I'm not logged in [duplicate]

I´m having problems with doing Shift + Enter in an object of SAP application.
This is the code I have:
If Dialog("SAP Logon 730").WinListView("SysListView32").Exist(100) Then
Dialog("SAP Logon 730").Activate
Dialog("SAP Logon 730").WinListView("SysListView32").Select sServer
Dialog("SAP Logon 730").Activate
SendKeysShell ("+{ENTER}")
End if
A list of server is displayed in the "Dialog" object. One must be selected (with the .Select) and then open using Shift + Enter.
The problem is that if I minimize the remote machine, the Sendkeys is not performed correctly.
If you minimise the Remote Desktop window (the window that displays the remote computer’s desktop), Windows switches the remote session to a GUI-less mode and doesn't display windows and controls. This means you can't interact with the desktop while the session is minimised and therefore your UFT/QTP script (that's what it looks like to me anyway) will fail.
As a possible workaround, you can try the following steps:
On your local computer, close all open Remote Desktop sessions.
Launch the Registry editor (regedit.exe).
Navigate to one of the following Registry keys, depending on whether you wish to modify the Remote Desktop settings only for the current user or for all users on the computer:
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client
Create a DWORD value named RemoteDesktop_SuppressWhenMinimized and set it to 2.
Close the Registry Editor.
Now, when you minimise the remote session on your local desktop, the GUI availability on the remote machine should be unaffected and your test case should continue to run OK.
Hope that helps...

C:\windows\SysWow64\CScript.exe window pop up

I created a macro in Excel and i am running it from a .vbs file. It's working fine on my laptop. I copied the same work on a new laptop and each time i am running the vbs file this window appears on the screen.
I have made some research and read that the situation i mentioned is happening when loading CheckNDISPort service on the startup. But i don't believe it's the reason because when i go to task manager and check in the startUp tab i don't find this service. Also when i restart my laptop i don't get this window, only when i am running my vbs file. I am sure there is any problem with my vbs file too because on the other laptops it's working fine.
Any suggestion please how to get ride of this pop up ? For now i am closing the window each time or ending the task from task manager but everytime i run it again so it pops up again.
Thank you very much.
Windows Scripting Host has two interpreter front-ends, wscript.exe and cscript.exe. cscript.exe is a console application and if cscript.exe is set as the default a console window will open every time you execute a script.
Run cmd.exe elevated as administrator and run wscript.exe //h:wscript.
Depending on the Windows version, you might also be able to right-click a .vbs file, select "Open with...", choose %windir%\system32\wscript.exe and check the "default" checkbox.

Google Drive as Service or background operation

I have a server thats does automatic backups, now i need to sync that backup files to google drive, but i dont want to login every day into windows server so google drive make the sync.
¿Does anyone know a way to sync or script to upload in background without user interacction?
Well i figured out, so i am posting for everyone who needs to run google drive sync app without enter to windows:
create a sheduled task with action start program pointing to: C:\Program Files (x86)\Google\Drive\googledrivesync.exe
add argunment: /autostart
mark execute to run if the user has not logged in
i have also marked execute with higher privileges
the trigger is at system starts with a delay of 30 seconds, it is very important to make a delay!
uncheck the option thats stops the task if it runs for more than x days, this is because google sync is always running in background.
now i have to copy the backups files to google drive folder with and cmd script + sheduled task.
If you are running on a Windows Server 2003 you can try the following to run Drive as a Service:
Download and install Windows Server 2003 resource kit which can be found here
Open a command prompt and run the following:
C:\Program Files (x86)\Windows Resource Kits\Tools>instsrv GoogleDrive "c:\Program Files (x86)\Windows Resource Kits\Tools\srvany.exe"
Next is to change the user for witch the newly added service “GoogleDrive” runs under. Change this to Administrator.
Type the following command in the command prompt to open the services snap in console:
services.msc
Choose properties on GoogleDrive service.
Click on tab “Log On”
Click “This account”, and select Admimistrator. Set appropriate password.
Click Apply and OK
Next is to setup some registry settings for the service. Open the registry editor by typing the following command into the command prompt:
regedit
Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\GoogleDrive
Create a new key “Parameters”
Add a new string value “Application”, (type REG_SZ). Set the value to the path to C:\Program Files (x86)\Google\Drive\googledrivesync.exe /autostart.
Close Registry Editor
Go back to Services, and start the GoogleDrive service
This was adapted from an article about running Dropbox as a service which can be found here.
Essentially the process is to create a Windows service using the 'srvany.exe' which is a Windows service wrapper that will run any program as a service.

Batch - Move File to Network Drive without being logged in

I have the following script which is setup as a task to automatically move a file to a mapped network drive. The problem is that this only works when a user is logged in and has an active Windows session open. However, if the user is logged off these backups wont happen as I believe it cannot find the network drive. This is running on a Windows 2003 Server. Is there anyway to alter the script to make sure it can connect to the networked drive while no active sessions are open?
The process I am using is to move the file, then delete the file to clear up hard-drive space, then a .exe is run to empty the recycling bin.
#echo off
move C:\StarshipBackup\*.* Z:\StarshipDataBackup
del C:\StarshipBackup\*.* /F /Q
C:\emptyrecycle.exe
You can mount the drive in the batch file. Add this before your move command:
net use z: \\yourserver\sharename
Of course, you need to make sure that the account the batch file runs under has permission to access the share. If you are doing this by using a Scheduled Task, you can choose the account by selecting the task, then:
right click Properties
click on General tab change account under
"When running the task, use the following user account:"
That's on Windows 7, it might be slightly different on different versions of Windows.

How to run something after Windows logon is fully done?

I have a system service running on my Windows machine that can impersonate the currently logged on user and launch applications on their behalf (including UI apps).
It works fine when the user is already logged on into their interactive session, their Desktop is created, and so on.
The startup of the service is Automatic, so it is started automatically after each reboot. If it attempts to run some program (that needs UI access) immediately after the service is started, that program may fail - possibly because the autologon process is still in progress, the Desktop is not created yet, etc.
The question is: if the service starts "early", how can it wait for the interactive session to be fully initialized (apart from waiting some arbitrary time, which is not optimal)?
Or, can the service be started "late"? Is there a registry key, or a folder, or something else, that I can use to delay the service startup to the moment when the Shell is ready and it is safe to launch UI applications?
The easiest two ways to "execute some code when a user logs on" is to write a .bat file, and either:
1) Put the .bat file in the startup folder
<= Note: Windows 7/Vista has a new location for "Startup folder"
... or ...
2) Create a new Task that calls the .bat file at login
I option "2)" gives you finer control. It also allows the .bat file to "Run as Administrator" if needed.
If you'd like to make the .bat file pause briefly (e.g. to make sure things are completely initialized", you can add "ping -w" to your .bat file.
EXAMPLE:
#rem Waits 5 seconds before continuing
ping 1.1.1.1 -n 1 -w 5000 > nul

Resources