Windows can display the current Username profile, by typing %username% at a command prompt. Does anyone know if APM5 can utilise this or use any other method to find the current user's name.
How can you pick up the Windows current Username
Collapse
X
-
Re: Windows current user
Thanks WORM - if anyone would know it was you, and a very quick response - thank you.
I had thought about using the GetLANinfo, but was put off that if the user was not on a LAN then it would return 'Unknown'. However, preliminary testing since your reply, seems to return the username even when I am disconnected from the network! I'll try some more tests, and once again Thanks
Comment
-
-
You could also do it this way. Download and install the Run Silent Plugin from my website (its free).
Once installed, enable it in AMS, then use this code.
Code:01 [i][COLOR='#008000']-- create text for batch file[/COLOR][/i] 02 sOut [COLOR='#FF0000']=[/COLOR] [COLOR='#800080']"echo %username% > %temp%\\username.txt"[/COLOR] 03 04 [i][COLOR='#008000']--write the batch file to the temp folder[/COLOR][/i] 05 TextFile[COLOR='#FF0000'].[/COLOR]WriteFromString[COLOR='#FF0000']([/COLOR]_TempFolder[COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR] [COLOR='#800080']"\\getname.bat"[/COLOR][COLOR='#FF0000'],[/COLOR] sOut[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'])[/COLOR] 06 [i][COLOR='#008000']-- execute the batch file silently (no command window)[/COLOR][/i] 07 RunSilent[COLOR='#FF0000'].[/COLOR]Exec[COLOR='#FF0000']([/COLOR]_TempFolder[COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR] [COLOR='#800080']"\\getname.bat"[/COLOR][COLOR='#FF0000'],[/COLOR] [COLOR='#800080']""[/COLOR][COLOR='#FF0000'])[/COLOR] 08 09 [i][COLOR='#008000']--get the result of the batch file[/COLOR][/i] 10 sName [COLOR='#FF0000']=[/COLOR] TextFile[COLOR='#FF0000'].[/COLOR]ReadToString[COLOR='#FF0000']([/COLOR]_TempFolder[COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR] [COLOR='#800080']"\\username.txt"[/COLOR][COLOR='#FF0000'])[/COLOR] 11 12 [i][COLOR='#008000']-- display username[/COLOR][/i] 13 Dialog[COLOR='#FF0000'].[/COLOR]Message[COLOR='#FF0000']([/COLOR] [COLOR='#800080']"User Name:"[/COLOR][COLOR='#FF0000'],[/COLOR] sName[COLOR='#FF0000'])[/COLOR] 14 15 [i][COLOR='#008000']--Clean up[/COLOR][/i] 16 File[COLOR='#FF0000'].[/COLOR]Delete[COLOR='#FF0000']([/COLOR]_TempFolder[COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR] [COLOR='#800080']"\\getname.bat"[/COLOR][COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] true[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] [b][COLOR='#0000FF']nil[/COLOR][/b][COLOR='#FF0000'])[/COLOR] 17 File[COLOR='#FF0000'].[/COLOR]Delete[COLOR='#FF0000']([/COLOR]_TempFolder[COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR] [COLOR='#800080']"\\username.txt"[/COLOR][COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] true[COLOR='#FF0000'],[/COLOR] false[COLOR='#FF0000'],[/COLOR] [b][COLOR='#0000FF']nil[/COLOR][/b][COLOR='#FF0000'])[/COLOR]
code "prettified" by AMS Code Pretty
Comment
-
-
I like that WORM - have downloaded your Runsilent and it works a treat. Thanks. Whilst on your website also bought your Sendkeys plugin. Just waiting for the download email now. I am currently working on an App that I will need to send key presses, so that was well timed. Thanks again mate.
Comment
-
-
If you're speaking of the plugin, then first you need to download and install it. Once its installed, you need to start/restart AMS, then choose Project -> Plugins, and enable the Run Silent plugin. If it doesn't show in the list, then you more than likely installed it to the wrong folder. Uninstall it, then reinstall reading very carefully the directions when installing.
If you still have problems, let me know.
Comment
-
Comment