Populate a Tscon command in a batch file with new qusers results - remote-desktop

I am using tscon to close a remote connection and leave the screen unlocked.
At the moment I am having to find the sessionname using quser.exe, and then manually update the batch file.
tscon rdp-tcp#20 /dest:console /Password:**********
I want to run the quser, then automatically update the batch file, so I can just run it without editing it...
Can anyone think of anything?
Thanks, Jon
I dont know what to try

Related

How do I remove an Error.error file being created and cannot be deleted?

How do I delete/remove the "Error.error" file when the system says it is not there but it is?
The Error.error file was created somehow and I do not know why or how. However, the issue is the system has created this 0 byte file called "Error.error" and it cannot be deleted, even if I try a "permanent" delete command. It also will not allow me to delete any of the folder directory hierarchy in which is resides. When I do try create it, rename it, or create a physical file with the same name and extension, or try to delete this file directly or indirectly I receive the following error message:
"Could not find this item: This is no longer located in C:\maps\test. Verify the items location and try again." Then it list "Error.error" and its information. However, it is there visually.
Any thoughts or suggestions on how to remove or correct?
Thanks!
I had a very similar issue not too long ago where I had a file that was created by another program and whenever I tried to access or delete it, windows would give an error message like "...This is no longer located in...".
If you're having the same problem I was, here's how I got rid of the file. Start a command prompt. In the command prompt, enter a command like del "\\?\<full path to file>". So if your file name is "Error.error" and it is located in the folder "C:\maps\test", the command you would enter is
del "\\?\C:\maps\test\Error.error"
You can delete a folder that windows won't let you access in a similar way by changing the command from "del" to "rd /S".
If you don't know how to start a command prompt, simply click the start button and type "command". The start menu should offer an option named something like "Command Prompt - Desktop app". That's what you need to start.
I found a good explanation of what the "\\?\" means here.

Execute a batch file from another batch while keeping previous console open

I want to execute a batch file from another batch file and I have been successful in doing so but the problem is once the 2nd batch is executed the 1st batch window closes. I want to keep the first batch window to stay open
The command I am using is :
1st.bat :
2nd.bat "path"
pause
Try this:
start "windowname" "file.bat"
Sorry if this doesn't work; I'm currently using a mobile phone.

How to update Target (right click properties) of an .exe using a batch script?

I would like to update the Target of an .exe using my batch file. Is it possible?
Basically, i would like to make my app auto-login by adding userid and password to it and i don't want to manually do this for every installation that i do.
So from Target: C:\Softwarebin\Software.exe to Target: "C:\Softwarebin\Software.exe -user:app -passwd: app1"
At the moment, i have to do this manually everytime i install our software for the users by right clicking the desktop shortcut and editing the Target field as above. It would be great to have a batch command which i could include in my install.bat file which would update this for me as well after the installation is complete.
Any suggestions please?
Thanks
irish
You can't change the target of the .exe itself, however, you can make\modify a shortcut with vbscript and run it from a batch-file the following way:
Set shell = CreateObject("WScript.Shell")
Set prog_shortcut = shell.CreateShortcut("Your_shortcut_location\Shortcut.lnk")
prog_shortcut.TargetPath = "C:\Softwarebin\Software.exe -user:app -passwd: app1"
prog_shortcut.Save
Notice that CreateShortcut also modify an existing shortcut, so it should do the trick.
You can run the vbscript from command afterwards if you need.

How to close a command window after batch file

I have a batch process in Win 8 that changes to a directory, runs MS Access to produce a text file ( that’s HTML with data, thought that fun), then starts an FTP process calling a text file that manages the upload. At the end of this I’m stuck with an open command window.
I’ve tried using “start” to start the ftp process, and I’ve played with using “exit” on the last line or not. Nothing is closing that window.
The File reads something like:
Cd\data
“c:\program files\office\msaccess” “c:\art\make_html_and_exit.mdb”
start ftp ftp.txt
exit
The window stays open.
As this must happen 4 times a day, I worry I'll annoy the user at the desk having to close the command window so often.
Yes, I know that this question has been covered before, but I can't get the window to close.
It is your "ftp-window" which is not closing. Right?
What are the contents of ftp.txt? The last line should be quit
By the way:
you should call ftp with
start ftp /s:ftp.txt
(see ftp /?)
This problem seems to have been caused by Logmein. When I was at the client’s site, the batch window closed fully. I then logged in remotely from a machine on the next desk and found the same failure to close.

How to log input and output of a batch file to a text file?

I have created a batch file with 2000 lines of code and which will peroform various operations in my daily work. For this batch file I have to give some inputs to enable/disable some of the operations. Finally the batch file is ready and working fine.
But I want to have a log file in which everything which is coming on the command window should be logged, including the inputs that I have given to the batch file and also the execution process.
Is there any way do like this? Any one of you can help me?
Thanks in advance...
Nagaraju
You are not telling how you are invoking the batch file. You could try adding redirection to the command line (batchfile.bat > filename.log), although that won't catch whatever you type in as input. You could, however, change the script to print out the input parameters so that they could be caught in the log file.

Resources