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

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...

Related

Automating user interaction from within Session 0

I am running on Windows Server 2012. I have a service that creates several processes, one of them is a GUI client. The process in high level is as follows:
Service runs a launcher exe
The launcher exe launches an AutoIT compiled exe
The AutoIT compiled exe launches a winform exe
The winform exe does two things:
a. It write a file to the disk on program startup (test.log)
b. It waits for a keyboard press "c" to write a second file to the disk (test2.log)
The AutoIT script does two things:
a. It launches the said winform exe
b. It sleeps for 5 seconds and then send "c" (Send command)
If I start running this chain manually (from step 2) - everything works fine and 2 files are being created. I guess this happens because I have an interactive session (specifically 2) so it's a no brainer here. However, if I run it from the service, everything runs in session 0 (I verified this with ProcessExplorer) but only the first file is being written. Meaning, the keystroke message was not read by the winform exe.
I read about Session 0 isolation which means that user input from other sessions can't interact with programs (services) running in session 0. However, all of the processes mentioned now run in the same session 0. So I'm not sure why my application doesn't get the keyboard strokes? Any workaround for this? Please note that running under a different session is probably not possible, as the server must run without user logged on and as far as I know, you can't launch a session yourself without logging into the system.
Any help is appreciated.
Thanks!
Your service probably runs under Local System or Local Service account (it's always "logged in" in some sense). But you can change this behavior to allow the service running under any specified account with access to the desktop.
Go to menu "Start->Computer->Manage".
In the "Computer Management" window select "Services and Applications->Services".
Find your service and call "Properties" by popup menu.
Open "Log on" tab.
You have 2 options here:
a. Choose "Local System account" radio button and check "Allo&w service to interact with desktop".
b. Choose "This account" and type or "Browse..." the account you need.
Option (b) could make sense if you set up an auto logon on the machine (in this case you may run as Administrator and have an access to the desktop simultaneously).
Option (a) is applicable only if you don't need running as Administrator. Hope it helps.

BGInfo error occurred opening the Default Desktop registry key

Running the very nice BGInfo tool to uniquely identify various computers. However, in trying to run on Windows 2008 Server R2, I am getting following error:
"An error occured opening the Default Desktop registry key. Please ensure the current user has rights to change the Logon Desktop settings: Access is denied."
The program is started via a shortcut placed in "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup", and that shortcut is specifying a .BGI configuration file (versus reading settings from the Registry). Thoughts on why the error happens for user other than the Administrator?
On a more in-depth level, I am curious if anyone knows why BGInfo must open the "default desktop registry key" and what it is updating in the "logon desktop settings" (phrase in quotes taken from the original error message)?
BGInfo needs to update the registry to set a default login desktop for all RDP users.
You need to run BGInfo with elevated privileges initially. That can be done as described by creed929 or by right-clicking on bginfo.exe and running as administrator. Once the settings are saved, subsequent user logins will not need the elevated privilege to see the BGInfo background.
From an administrator account. I was able to right click on bginfo.exe. Go to Compatibility tab and check the Run this program as an administrator. This seemed to then allow me to apply the settings without the Default Desktop registry key error.

Windows 2008 Remote Desktop will not copy+paste

I have just set up a Guest Windows 2008 R2 Standard Edition 64bit (VirtualBox on Windows 7 64 bit host) for some testing.
I have found that while "inside" the remote desktop environment (i.e. I remote onto the guest ip from the host) that copy and paste does not work. When I say "does not work" let me be explicit.
Assume I am logged onto the Win2008 machine via RDC
Nothing is in the copy/paste buffer. I can mouse click some text and then rclick copy. I can then right click and click "paste" but nothing happens. I can see the "choice" is enabled to paste bu nothing happens. The caret stays put.
CTRL+C / CTRL-V / CTRL-X does not work in RDC land
I am not talking about going in-between copy/paste RDC land/host land.
HERE is the double whammy: when I do the above it then "infects" my host pc so that copy paste is unavailable there too. if PRT SCR doesn't work any more.
I have tried:
restarting the guest os and host os
in group policy editor I have disabled "do not allow clip board redirection" ( I can't give you the full path to this copy/paste just broke again)
I have made sure that in RDC "options" for local resources include clipboard.
NB: if I don't touch RDC at all and log into the guest OS via the console copy paste works perfectly
Kill the rdpclip.exe process using the Task Manager. Then, create a new process named rdpclip.exe. This will solve your problem.
Follow these steps in Remote Machine.
Stop the rdpclip process
Open Task Manager.
Go to process tab and find rdpclip
Choose rdpclip and End that task.
Start rdpclip.exe
Go to start menu and open Run command
Open rdpclip.exe and click Ok button.
Copy paste should work now.
it appears this is a flaw with VirtualBox
these posts covers it
https://forums.virtualbox.org/viewtopic.php?f=6&t=44498 (read the last post)
https://github.com/FreeRDP/FreeRDP/issues/230
(In VirtualBox) SETTINGS->GENERAL->[Advanced]->Shared Clipboard {disabled}
There are multiple things to check.
Restarting rdpclip.exe is a worthy try if the copy/paste fails sporadically, meaning we might on a process in a previous session.
On the client side, we check the RDP Options. Click on the Show Options button in the bottom, pick the third tab Local Resources. Make sure Clipboard is checked.
On the remote server side, we want to check Remote Desktop Session Host Configuration (Win Server 2008+).
Double click the connection to open its Properties window.
In the tab named Client Settings, Make sure Clipboard is not disabled.
We need to log off from the remote desktop.
Workaround
Use an online shared text box like this one:
https://pastebin.com/

VB6 Application on Windows 7 Cannot Access Mapped Drives

I have a VB6 application which links to several POS terminals from a Windows 7 32-bit machine. The POS terminals are mapped to the Windows 7 machine and I can access the POS terminals from the Windows 7 machine from Explorer or via the cmdline/shell.
The application has been updated to ADO 2.8 and all other controls and components I no longer had source code for have been re-written. After a few annoying hiccups, I got the application to recompile on the Windows 7 computer without errors.
Now come the problems. The VB6 application cannot see or navigate to any mapped drives! I have tried twiddling UAC settings; I have set the app to run in Windows XP SP3 mode; I have tried running as Administrator. None of these things (and many permutations of these) work.
Any suggestions on how to make this work?
Adding this registry setting solved the problem for me: http://technet.microsoft.com/en-us/library/ee844140%28v=ws.10%29.aspx.
To work around this problem, configure the EnableLinkedConnections
registry value. This value enables Windows Vista and Windows 7 to
share network connections between the filtered access token and the
full administrator access token for a member of the Administrators
group. After you configure this registry value, LSA checks whether
there is another access token that is associated with the current user
session if a network resource is mapped to an access token. If LSA
determines that there is a linked access token, it adds the network
share to the linked location. To configure the EnableLinkedConnections
registry value
Click Start, type regedit in the Start programs and files box, and
then press ENTER.
Locate and then right-click the registry subkey HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System.
Point to New, and then click DWORD Value.
Type EnableLinkedConnections, and then press ENTER.
Right-click EnableLinkedConnections, and then click Modify.
In the Value data box, type 1, and then click OK.
Exit Registry Editor, and then restart the computer.
I believe you are having trouble because casual drive mapping is per-user, and on a UAC system Administrators group users have two separate contexts (one for each token: SU & elevated).
There is such a thing as a system level drive mapping, which is one done under the System user (NT Authority\System). When you map a drive under this account, and map it persistently, all users can see and use the mapping (subject to the usual access rights for files there).
The normal way you do this is via Domain-level GPOs (Group Policy Objects), which means bribing your local box jockeys if in a corporate managed LAN environment.
One way to do this in a Workgroup machine is to map the letter as System via the AT command, from an elevated command prompt:
at 8:53 am "net use m: \\MediaShare\MyLibrary
ThePW /user:MediaShare\TheUser /persistent:yes > nul"
There the remote server is MediaShare, user TheUser, password ThePW, and 8:53 AM is a minute or two in the future to avoid accidentally scheduling this for tomorrow.
But this fails on Vista and later due to Session 0 Isolation!
So... use the 3rd alternative at Run CMD.exe as Local System Account which is the same thing mentioned by ForcePush's reply to How to map a network drive to be used by a service.
I believe that's what you are after here.
don't know if you ever figured this one out but for me it was the ChDir command (even with the registry fix above).
I had in my code
ChDir "P:\Temp\VidCap\Cam1\" 'I almost never use ChDir
Open "list.txt" For Output As #1
and all the VB6 inbuilt file commands looked straight though any operations, no errors, no nothing. I solved it by explicitly having the path, (in my code it was in a string but you could have it explicitly):
dd = "P:\Temp\VidCap\Cam1\"
Open dd & "list.txt" For Output As #1
works as expected.
hope this helps
H
Try this:
Open command prompt as administrator, and type this in:
net use Z: \\IP Address\share /user:you passwd /persistent:Yes
Change "IP Address", the "share" name, and your username and password as needed.
The author of this is howtogeek (source).
I had same problem. VB6 kept crashing when trying to access USB and mapped drives using the Commondialog method, even though the drives and files were all accessible OK via Explorer. Problem is the drives were not set as shared.
Solved by selecting the connected USB drive in explorer and then right click to
select Properties.
Select Sharing Tab
Select Advanced Sharing
Set the sharing and user rights as needed. May need to have local admin rights.

selenium rc captureEntirePageScreenshotToString triggers FileNotFoundException

I'm using selenium rc to do functional website testing and I've recently experienced a mysterious issue with safari and opera.
When a test fails I make a screenshot using the captureEntirePageScreenshotToString command as well as retrieving the html source.
Sometimes however this fails with a FileNotFoundException:
java.io.FileNotFoundException: C:\DOKUME~1\selenium\LOKALE~1\Temp\customProfileDir8aa20800ab1a46dbb3ef71d4d2d31b77\screenshots\page-screenshot-8aa20800ab1a46dbb3ef71d4d2d31b77.png
Is this a selenium bug? How can I workaround this issue?
I'm using selenium rc standalone 2.0a4.
thanks,
hans
So I've been using the 'captureScreenshotToString' method which is a little different, but still provides the means to get a screenshot from a remote selenium instance.
The large different/problem with this approach is that it requires the selenium server to be an unlocked windows session so it can access the display buffer to get at the physical screen. This has created problems with my headless selenium-grid machines, that I remote desktop into to administrate/troubleshoot.
In order to workaround that I've used an autologon script for this msdn article, and setup a task to restart the computer after a remote desktop session ends.
To setup Auto-Restart after remote desktop disconnect:
Open up the task scheduler
Create a new task (Create task...)
Set the name of the task to be 'Auto-Restart after remote desktop disconnect'
In the General tab, change the user to NT AUTHORITY\SYSTEM
Change to the Triggers tab, click New... to create a new trigger
Set the Begin the task to 'On disconnect from user session'
By default, it will be for any user, and from remote computers, which is exactly what we are looking for.
Change to the Actions tab, click New... to create a new action
Select the action to be Start a program. Set the program to be 'C:\Windows\System32\shutdown.exe', and then add '/r /f /t 5' (Restart, Force quit applications, wait 5 seconds to restart).
Fair warning, this is not the most secure way to have a computer sitting around
I suggest you use the Apache Commons FileUtils function makeDirs() to create all the parent directories of the directory where the png image will be located.

Resources