@@ -164,7 +164,7 @@ void ShowUsage(void) {
164
164
<< std::endl
165
165
<< L" IEDriverServer [/port=<port>] [/host=<host>] [/log-level=<level>]" << std::endl
166
166
<< L" [/log-file=<file>] [/extract-path=<path>] [/silent]" << std::endl
167
- << L" [/whitelisted-ips=<whitelisted-ips>]" << std::endl
167
+ << L" [/whitelisted-ips=<whitelisted-ips>] [/version] " << std::endl
168
168
<< std::endl
169
169
<< L" /port=<port> Specifies the port on which the server will listen for" << std::endl
170
170
<< L" commands. Defaults to 5555 if not specified." << std::endl
@@ -188,7 +188,9 @@ void ShowUsage(void) {
188
188
<< L" /silent Suppresses diagnostic output when the server is started." << std::endl
189
189
<< L" /whitelisted-ips=<whitelisted-ips>" << std::endl
190
190
<< L" Comma-separated whitelist of remote IPv4 addresses which" << std::endl
191
- << L" are allowed to connect to the WebDriver server." << std::endl;
191
+ << L" are allowed to connect to the WebDriver server." << std::endl
192
+ << L" /version Displays version information and exits. All other arguments" << std::endl
193
+ << L" are ignored." << std::endl;
192
194
}
193
195
194
196
int _tmain (int argc, _TCHAR* argv[]) {
@@ -263,78 +265,83 @@ int _tmain(int argc, _TCHAR* argv[]) {
263
265
implementation.begin (),
264
266
toupper);
265
267
266
-
267
- void * server_value = start_server_ex_proc (port,
268
- host_address,
269
- log_level,
270
- log_file,
271
- executable_version + L" (" + executable_architecture + L" )" ,
272
- implementation,
273
- whitelist);
274
- if (server_value == NULL ) {
275
- std::wcout << L" Failed to start the server with: "
276
- << L" port = '" << port << L" ', "
277
- << L" host = '" << host_address << L" ', "
278
- << L" log level = '" << log_level << L" ', "
279
- << L" log file = '" << log_file << L" ', "
280
- << L" whitelisted ips = '" << whitelist << L" '." ;
281
- return ERR_SERVER_START;
282
- }
283
- if (!silent) {
284
- std::wcout << L" Started InternetExplorerDriver server"
285
- << L" (" << executable_architecture << L" )"
286
- << std::endl;
287
- std::wcout << executable_version
288
- << std::endl;
289
- std::wcout << L" Listening on port " << port << std::endl;
290
- if (host_address.size () > 0 ) {
291
- std::wcout << L" Bound to network adapter with IP address "
292
- << host_address
293
- << std::endl;
268
+ if (args.is_version_requested ()) {
269
+ std::wcout << L" IEDriverServer.exe"
270
+ << L" " << executable_version
271
+ << L" (" << executable_architecture << L" )" << std::endl;
272
+ } else {
273
+ void * server_value = start_server_ex_proc (port,
274
+ host_address,
275
+ log_level,
276
+ log_file,
277
+ executable_version + L" (" + executable_architecture + L" )" ,
278
+ implementation,
279
+ whitelist);
280
+ if (server_value == NULL ) {
281
+ std::wcout << L" Failed to start the server with: "
282
+ << L" port = '" << port << L" ', "
283
+ << L" host = '" << host_address << L" ', "
284
+ << L" log level = '" << log_level << L" ', "
285
+ << L" log file = '" << log_file << L" ', "
286
+ << L" whitelisted ips = '" << whitelist << L" '." ;
287
+ return ERR_SERVER_START;
294
288
}
295
- if (log_level. size () > 0 ) {
296
- std::wcout << L" Log level is set to "
297
- << log_level
289
+ if (!silent ) {
290
+ std::wcout << L" Started InternetExplorerDriver server "
291
+ << L" ( " << executable_architecture << L" ) "
298
292
<< std::endl;
299
- }
300
- if (log_file.size () > 0 ) {
301
- std::wcout << L" Log file is set to "
302
- << log_file
293
+ std::wcout << executable_version
303
294
<< std::endl;
295
+ std::wcout << L" Listening on port " << port << std::endl;
296
+ if (host_address.size () > 0 ) {
297
+ std::wcout << L" Bound to network adapter with IP address "
298
+ << host_address
299
+ << std::endl;
300
+ }
301
+ if (log_level.size () > 0 ) {
302
+ std::wcout << L" Log level is set to "
303
+ << log_level
304
+ << std::endl;
305
+ }
306
+ if (log_file.size () > 0 ) {
307
+ std::wcout << L" Log file is set to "
308
+ << log_file
309
+ << std::endl;
310
+ }
311
+ if (implementation.size () > 0 ) {
312
+ std::wcout << L" Driver implementation set to "
313
+ << implementation
314
+ << std::endl;
315
+ }
316
+ if (extraction_path_arg.size () > 0 ) {
317
+ std::wcout << L" Library extracted to "
318
+ << extraction_path_arg
319
+ << std::endl;
320
+ }
321
+ if (whitelist.size () > 0 ) {
322
+ std::wcout << L" IP addresses allowed to connect are "
323
+ << whitelist
324
+ << std::endl;
325
+ } else {
326
+ std::wcout << L" Only local connections are allowed"
327
+ << std::endl;
328
+ }
304
329
}
305
- if (implementation.size () > 0 ) {
306
- std::wcout << L" Driver implementation set to "
307
- << implementation
308
- << std::endl;
309
- }
310
- if (extraction_path_arg.size () > 0 ) {
311
- std::wcout << L" Library extracted to "
312
- << extraction_path_arg
313
- << std::endl;
314
- }
315
- if (whitelist.size () > 0 ) {
316
- std::wcout << L" IP addresses allowed to connect are "
317
- << whitelist
318
- << std::endl;
319
- } else {
320
- std::wcout << L" Only local connections are allowed"
321
- << std::endl;
322
- }
323
- }
324
330
325
- // Create the shutdown event and wait for it to be signaled.
326
- DWORD process_id = ::GetCurrentProcessId ();
327
- vector<wchar_t > process_id_buffer (10 );
328
- _ltow_s (process_id, &process_id_buffer[0 ], process_id_buffer.size (), 10 );
329
- std::wstring process_id_string (&process_id_buffer[0 ]);
330
- std::wstring event_name = IESERVER_SHUTDOWN_EVENT_NAME + process_id_string;
331
- HANDLE event_handle = ::CreateEvent (NULL ,
332
- TRUE ,
333
- FALSE ,
334
- event_name.c_str ());
335
- ::WaitForSingleObject (event_handle, INFINITE);
336
- ::CloseHandle (event_handle);
337
- stop_server_proc ();
331
+ // Create the shutdown event and wait for it to be signaled.
332
+ DWORD process_id = ::GetCurrentProcessId ();
333
+ vector<wchar_t > process_id_buffer (10 );
334
+ _ltow_s (process_id, &process_id_buffer[0 ], process_id_buffer.size (), 10 );
335
+ std::wstring process_id_string (&process_id_buffer[0 ]);
336
+ std::wstring event_name = IESERVER_SHUTDOWN_EVENT_NAME + process_id_string;
337
+ HANDLE event_handle = ::CreateEvent (NULL ,
338
+ TRUE ,
339
+ FALSE ,
340
+ event_name.c_str ());
341
+ ::WaitForSingleObject (event_handle, INFINITE);
342
+ ::CloseHandle (event_handle);
343
+ stop_server_proc ();
344
+ }
338
345
339
346
::FreeLibrary (module_handle);
340
347
::DeleteFile (temp_file_name.c_str());
0 commit comments