Call webservice from batch file calling in scheduled task - batch-file

It's several days I search for a problem. I've create an Intranet (Authenticate mode windows allow member of domain) and I a webservice can be called by asmx file
I create a bat file to be use in scheduled task
#echo off
start /MIN iexplore.exe http://server/WS.asmx/Importation
Timeout /T 80 /NoBreak>NUL
taskkill /F /IM iexplore.exe /T
Until now it was good. But from severals days now I don't see the calling asmx correctly (I create a log file and it's empty.
When I call this WebService from my Intranet : it's Ok
I notice now when I run my batch file manually it's ask me a username and password
I look several sample but don't find the good option.
Why Ask me a password when my task have the goods credentials. And How open this asmx with a username/password from scheduler?
Thanks for your help

Finally, I found a way...
In Internet option u have a checkbox "activate the protected mode" uncheck it
And I add my Intranet to Intranet Site
Like this server isn't use directly (only resquest by Excel) and like it's inside protected struture. The risk are very limited.
I hope that can help

Related

Azure Active Directory Server 2016 Group Policy Startup Applications (Chrome) not loading on client workstations

Hi I'm trying to implement a Group Policy in our domain that forces Google Chrome to be added to client startup applications. I've added a GPO and added the key:
Computer Configuration > Administrative Templates > System > Logon > Run These Programs at User Logon
In the "Items to run at logon" I've added the path to chrome.exe (with quotes) like so:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
I've then linked to the Object in our Domain's User and Computer OUs.
I've also pushed the update out to clients and confirmed they have updated GP.
However Chrome does not start when users boot into their laptops.
I'm hoping someone can shine a light on what I've done wrong/what I've forgotten to do - any help much appreciated!
Summarize the comment link as a reply to close this issue.
Per duenni1's comment it looks like the most successful way people are reporting is to use the startup folder instead of the logon group policy. "In my opinion the correct solution: use GPP to manage shortcuts in startup menu folder. Simply create a startup shortcuts."
Could throw it in this directory:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
This will launch the program when they login, we do this to force users into our IM client
https://community.spiceworks.com/topic/1369848-run-these-programs-at-user-logon
If you really want this method to work, I'd start troubleshooting here:
1) is there already a GPO in place that will perform Run These Programs at user logon? That may be the winning GPO
GPO Run these programs at user logon not taking effect
2) According to the official docs, no error is a path issue ( I think your usage of quotes is correct but out of curiosity I'd be curious if removing the quotes has a change).
NOTE: If the program does not run, make sure the path is correct. The program does not run (and no error message is displayed) if the path is not found.

Batch file script that will check if the user is idle, then initiate the rest of the script

I wrote a script that will log someone out of the ticketing system I use at my company, is it possible to create a script to check if the user has been idle for about 5 minutes (i.e, no keystrokes or mouse movement) one they're idle initiate the script I wrote to log them out. Once they're logged out the script would need to be restarted. But since there won't constantly be someone on submitting a ticket can you also make so it only reactivates the idle timer once someone initiates another keystroke/mouse movement?
This is my script:
#echo off
Taskkill /im firefox.exe
CD C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\profilename
del *"cookies.sqlite"*
CD C:\Program Files (x86)\Mozilla Firefox
start firefox.exe http://sysaid.sdairy.com/Login.jsp
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate("Mozilla Firefox")
WshShell.SendKeys "{ALT}", "{TAB}"
(This just closes the browser, deletes the cookies then restarts the browser in the webpage I need and alt tabs to make sure that the browser window is in front of the desktop).
Let me know if you need more information please!
Thank you in advance.

Deleting files within a directory through remote 3rd party service

I am trying to use a service called LogMeIn to delete folders within a user profile's directory. When run locally, this obviously works. Very simple, as I am fairly new to batch files.
pushd %homepath%\Tracing
Echo Y | DEL *.*
Now, where I run into the problem is when I run it through LogMeIn. This service is for deployment and sends it to all the machines linked to it. It has me put in credentials that will work on all of the machines (network admin) so it can deploy the batch file and there is no way to work around it. Instead of going to C:\Users\tirefire, it now goes to C:\Users\Admin. Any thoughts as how to efficiently navigate to the desired user profile that is currently logged in? Every system is identical. Windows 7 Service Pack 1.
Couldn't find anything online regarding this issue directly. Thanks in advance!
Logmein will only log onto the profile that you have setup to access that computer. For example if your credentials are admin/pass you will get the admin profile, for tirefire/pass you will log on as TireFire.
Prior to logging in you will not be able to see who is logged in.
This is not the answer your looking for but it is the limitation of the software.
You could use a batch like:
CD..
FOR /D %%P IN (*.*) DO DEL /S/Q %%P\TRACING\*.*
This will look in the folders under c:\users (/D) and assign all user folders to the variable (%%P) and delete (DO DEL) anything in the tracing folder (%%P\TRACING*.*) for all users on the machine.
Source: I use logmein daily to log onto machines that we service.

login to remote using "mstsc /admin" with password

I want to use mstsc /admin to login to a server silently. My batch file reads the code as
mstsc /v:xxx.xxx.xxx.xxx /admin
But it ask me to enter password. Can anyone help me to skip this step?
I went on to Google and found this site. But I am very new to this stuff (scripting) and could not understand what to do with given code. Is it a vbscript file? Can I do the same thing with a batch file. Please elaborate and I request you to spoon feed. This is not my arena but still I am pushed to fight without weapons.
My basic need is to kick off all users from a remote desktop except mine to perform some maintainable work. Thanks.
Re-posted as an answer:
Found an alternative (Tested in Win8):
cmdkey /generic:"<server>" /user:"<user>" /pass:"<pass>"
Run that and if you run:
mstsc /v:<server>
You should not get an authentication prompt.
the command posted by Milad and Sandy did not work for me with mstsc. i had to add TERMSRV to the /generic switch. i found this information here: https://gist.github.com/jdforsythe/48a022ee22c8ec912b7e
cmdkey /generic:TERMSRV/<server> /user:<username> /pass:<password>
i could then use mstsc /v:<server> without getting prompted for the login.
to be secured, you should execute 3 commands :
cmdkey /generic:"server-address" /user:"username" /pass:"password"
mstsc /v:server-address
cmdkey /delete:server-address
first command to save the credential
second command to open remote desktop
and the third command to delete the credential for security reason
all of these commands can be saved in a batch file(bat).
(if you save these command in a batch file, third command will not be executed until you close the remote desk)
Same problem but #Angelo answer didn't work for me, because I'm using same server with different credentials. I used the approach below and tested it on Windows 10.
cmdkey /add:server01 /user:<username> /pass:<password>
Then used mstsc /v:server01 to connect to the server.
The point is to use names instead of ip addresses to avoid conflict between credentials. If you don't have a DNS server locally accessible try c:\windows\system32\drivers\etc\hosts file.
It became a popular question and I got a notification. I am sorry, I forgot to answer before which I should have done. I solved it long back.
net use \\10.100.110.120\C$ MyPassword /user:domain\username /persistent:Yes
Run it in a batch file and you should get what you are looking for.
Save your username, password and sever name in an RDP file and run the RDP file from your script
The Command mentioned above didn't work for me (Windows 11)
cmdkey /generic:"server-address" /user:"username" /pass:"password"
When i listed the cmdkeys using the commad:
cmdkey /list
I saw, that a legacy target was added. Adding a specific TERMSRV-Target worked for me:
cmdkey /add:Domain:target=TERMSRV/<SERVER> /user:<DOMAIN>\<USER> /pass:<PASSWORD>

Log in to windows by .bat file

Here's the situation: I've got .bat file that is being started by windows scheduler every 15 min. However, when system logs off user - actions are not being performed. I'd like to know, if it is possible to add some code to .bat file to make it log in to system again ?
When the user logs out, if the screen goes to a CTRL+ALT+DEL login screen, good-luck-chuck. No one has found a way to force windows to recognize CTRL+ALT+DEL from any programming language. Not even VBScript SENDKEYS will do it. However, if it goes directly to the user login to enter the name and password you can create a small .vbs sendkeys script to auto-login the user prior to running your .bat:
login.vbs
set wshShell = WScript.CreateObject("WSCript.shell")
wshShell.sendkeys "Username"
wscript.sleep 1000
wshShell.sendkeys "{Tab}"
wscript.sleep 1000
wshShell.sendkeys "Password"
wscript.sleep 1000
wshShell.sendkeys "{ENTER}"
WScript.Quit
Throw it into windows scheduler to run even if user is logged off. Or better yet, if you want to have it auto-login the user say 15 minutes after they log out, you can add it to the local Group Policy for that machine:
In RUN type gpedit.msc navigate to Local Computer Policy -> User
Configuration -> Windows Settings -> Scripts (Logon/Logoff) Double
click on Logoff and hit Add... In script name, enter the path of your
.vbs and hit ok. At the beginning of the .vbs file, add
wscript.sleep 900000
That will force it to wait 15 minutes before running the rest of the script automatically when a user logs off.
There is an option in the Tasksheduler wheter to run the task too if the user is logged off. Activate that and it should work fine.

Resources